Lucid dreaming is how I was able to conquer my constantly reoccurring nightmares from when I was a kid.
I didn't know there was a name for it, but eventually I realized in the scariest moments that I had the ability to "shape" reality
within my dreams.
More to the topic, the brain knows, but I had a dream a week ago that a man came to my door step, I opened the door, and he shot me
point blank in the forehead. I was still somewhat inbetween dreaming and waking up, and I made peace with my death.
The joke was on me, I woke up

Someone could have offed me at that moment before I woke up and it wouldn't have changed anything.