sounds a bit like night terrors mate, I suffered for years with them and still do.
Its important to get grounded when they happen, as like you say its so real and can be jarring.
Beathing helps, either square breathing if you can focus on something or if its dark using a nose breathing technique, also strong flavoured sweets next to your bed, like fishermen's friends to break the moment and bring you back to the now, to end the racing thoughts as quickly as possible as you will be in fight or flight mode.
The nose breathing works like this.
use you thumb to block one side of you nose breath in and out with the other side then swap to your index finger to block the other side of the nose, breath in and out again.
The thinking about which finger or thumb to use with the breathing takes your mind of the thoughts as you are focused on the movement of fingers and the breathing, its not prefect but has helped me in the past.
edit :-
Found a video that explains it better than I did.
You must be logged on to see media items