For a number of years now I've been able to tell the threatening person/creature during the dream - you're not real, go away. They go away.
This started when I dreamt about someone being in my house. I was terrified of knives and he had a knife and a phone - telling me to find him inside the house. I woke up several times but returning to the same dream. Eventually in my dream I run outside and refuse to go back inside but it gave me a sense of escape which gave me time to think in my dream. I thought - is there really someone in the house? Is this real or is it just a dream. I recognized in my dream that I was dreaming, told myself this is just a dream and went back inside (in my dream), back to bed and slept till morning with no further nightmares.
The last time was a few weeks ago. Dreamt that a gila monster had come out from under a truck and was hissing at me. I woke up and thought that's not real, there are no gila monsters here. Back to sleep, told the gila - you're not real, go away. It went away. Immediately an exotic poisonous snake came to me over my bed. I woke up and thought - oh yeah the old snake dream, thats not real. Back to sleep I told the snake, you're not real, go away.It went away. Then dreamt that a man was up on my roof trying to find a way in. Without waking I realized that my roofline was way to high and steep for anyone to be walking around up there and told the guy, you're not real, go away. He went away - no more dreams for rest of the night.
After it happened the first time with the home intruder, I started telling myself what to say in a dream while still awake in the case of a nightmare. Especially when they were more often. Pretty cool to have the ability to change the direction of a dream while sleeping.

Maybe someone here knows how to manage it on purpose - mine was more by accident so I don't know what part of the brain gets the message or what state of mind - trance happens to get a message like that.