I'm not sure if you're seeing a doctor or therapist, but I understand the fear of professionals and how they may (and sometimes do) abuse their power.
If you tell a therapist that you have violent thoughts but that you do NOT plan to act on them, any therapist who is competent would not lock you up. And would never throw away the key.
And most therapists are competent. I suggest you see a Clinical Psychologist or psychoanalyst, both are highly trained and intelligent professionals.