When I have a nightmare, there's usually nothing I can do to calm down until about five minutes later. Getting out of bed is probably a good one, because it forces you to become properly awake. However, I can offer advice for how to make sure you don't go back into a nightmare when you fall asleep again, which used to happen a lot to me.

The solution's simple - turn the pillow over.

I really don't know why this works, but it does.