Teebs, you have my sympathy on this one, it's an issue I've been struggling with for a few years now.
I haven't yet found a way to 'make it stop', but I have found some ways to reduce the length of the panic attack after I wake up, perhaps my experience can help you.
Usually, if I wake up in a panic attack, I need to first remind myself where I am and find something familiar and solid to know that I am still okay and things haven't changed much since I went to sleep. (You may or may not find comforting, but I find comforting because if things haven't changed that probably means that nothing drastic or bad has happened)
The next thing I do is try to halt any anxious thoughts that might be buzzing about in my brain by distracting myself (Either I'll get up and take a shower, or I'll read a bit of a book, or sometimes it's just as simple as trying to actively think about something else -- anything that can keep my attention.)
After that I do some self-talk, reminding myself that what I'm feeling is just the chemicals in my body, an adrenal response that will be over soon and I'll be fine, there's nothing I need to be worrying about right this minute, and if it's important I'm better off dealing with it while rational and calm so I don't need to worry.
If I'm still not very calm or it's taking a while to calm down, I might try to think actively about how I feel when I'm calm, to try to push myself towards that state. (It doesn't always do much, but sometimes it can help)
I do this in a cycle, and what I've found is that if I do it every time (even if I do it out of order) my brain knows I'm going to calm down soon, it anticipates the process the same way as you'd get hungry if you always ate at the same time of day, or with the same plate and you saw that plate, it's conditioning, and so using that I can calm down faster.
Though I do seem to have hit a bit of a hard limit of at least 5-10 minutes before it's mostly over and I'm only anxious not panicking, and can often get back to sleep. Really that's not all that bad considering I started off not sleeping for the rest of the night and even after the panic stopped I'd still feel very anxious.
Davit may have been onto something with the identifying of your triggers. I don't have those kinds of 'triggers' I don't think about anything worrying before I go to sleep (or I wouldn't sleep) and when I wake up in the middle of a panic attack, I don't always know why I'm feeling panicked and don't have any accompanying anxious thoughts, just the physical side of things, I call it chemical panic, or body panic. Those are the most common for me, and frustrating because I don't think I can prevent them.
But if you *do* have triggers, or specific thoughts that get to you when you first wake up with one, you should definitely work with what you have and try to prevent the panic before it wakes you up. If your sleeping brain doesn't hit any triggers, or if it can deal with them when it trips over them, you should have an easier time of it. Likewise, having a calm-down cycle that you follow can help over time.. It took about a year for mine to really start being effective so be patient with yourself.
Hope that helps
- Ivy