All of us have nightmares. Maybe in your nightmare you’re being chased by some terrifying but unknown entity. Maybe you’re surrounded by bloodthirsty vampires or hordes of zombies. Maybe you’re trapped in a room with snakes or spiders or any other animal you fear. Maybe you or a loved one is involved in a car wreck or a violent assault.

Maybe you keep having this nightmare over and over. And it’s so real, so vivid, so frightening that the last thing you want to do is fall back asleep.

According to Amy Mistler, Ph.D., a clinical psychologist with specialty training in trauma and health psychology, nightmares may trigger a whole host of negative emotions: Fear. Terror. Sadness. Shame. Anger. Loss.

There are several reasons why we have nightmares. Some theories surmise that dreams reflect emotions we’ve experienced during the day, Mistler said. “[A] nightmare may reflect daytime distress.”

It also might reflect trauma. If you’ve experienced a traumatic event, it’s common to have nightmares right after, Mistler said. This may be our mind’s way of trying to process and make sense of what happened, she said.

And in some cases, our minds produce nightmares simply out of habit. That’s because our brains get better at anything they do over and over, Mistler said. For instance, whether you’re practicing a sport or playing a musical instrument, parts of your brain become stronger or more active so you can engage in these new movements, she said.

The same can happen with nightmares. “When the brain produces the dream over and over, parts of the brain involved in facilitating the nightmare become stronger and more active. [Consequently] the nightmare will become more and more likely to come up when we are asleep.”

So what can you do?

According to Mistler, Imagery Rehearsal Therapy is an effective approach for eliminating ongoing nightmares. It’s “based on the idea that the mind produces the nightmare out of habit, a habit that can be broken.”

If you’re having recurring nightmares, you can try this technique on your own. If you’re also having additional symptoms, such as anxiety, depression or PTSD, consider working with a trauma-focused therapist, Mistler said. This way you’re “addressing everything.” A therapist can help you process the trauma in a safe space.

“When people successfully recover from a trauma, they allow themselves to think about the trauma and to feel their emotions. [As a result] they can make sense of what happened and organize the memories.”

Trauma memories tend to be disorganized, because of the intense emotions associated with it. Trauma can challenge your beliefs about yourself, others and the world, Mistler said. Working with a therapist also helps you develop healthy belief systems about all three.

Below, Mistler shared how to practice Imagery Rehearsal Therapy on your own:

1. If you’re having several recurring nightmares, pick one nightmare to work with.

If you’ve experienced trauma, pick a nightmare that doesn’t involve reliving the event. Start with a nightmare that’s less intense. Also, focus on one nightmare at a time until it’s resolved. Sometimes a nightmare resolves by transforming into something more neutral or positive. Other times, people stop having the nightmare altogether.

2. Rewrite the story of your nightmare with a different ending.

Revise the ending so it’s peaceful or emotionally neutral or positive. Don’t create another violent ending, where you win the fight, for instance. Again, it’s important that the ending is calming and promotes sleep.

Mistler shared these examples: One client, a veteran, had a recurring nightmare about being trapped in a room with exploding grenades. He revised the ending so the grenades explode into flowers, a prank created by his buddies.

Another veteran lost his friend in an IED explosion. He had nightmares about being in a convoy together, his friend’s vehicle hitting an IED and seeing all the graphic details of his death. When he rewrote the ending, he and his friend are still in a convoy, but there’s no explosion. They drive to another post and eat lunch together.

A woman Mistler was working with had nightmares about being chased by someone (which wasn’t connected to any trauma). She rewrote the ending so that the person simply turns around and goes somewhere else. She walks the other way, visiting a coffee shop to look at artwork.

3. Each night before falling asleep, visualize the dream with the new ending.

Then practice a relaxation exercise, such as a guided meditation. Mistler shared these links, where you can find free guided recordings:

After practicing this technique every night, some people find that their nightmares go away after a week or several weeks. Mistler suggests her clients practice for a week after their nightmare stops to solidify the results.

Again, if you’re experiencing other symptoms with your nightmares, find a therapist who specializes in trauma so you can safely process the event and get better. Which you will.

Man having a nightmare photo available from Shutterstock