I understand what you're going through in fact that's why I'm on here right now, I was laying down for bed and was just about to fall asleep when the thoughts just flooded my brain, what if this is it? what if I don't wake up tomorrow? What happens when we die, is there really an afterlife? Stuff like that... and I had a panic attack, It's 2:30 in the morning all I want to do is get sleep but of course that's lost now. I haven't figured out how to make these thoughts stop but I have figured out how to make them subside. When these thoughts hit you get up busy yourself with something else, It's not permanent but it makes it easier to get though the night.
Talking to people is probably the best way to deal with it, I know I'm always afraid to talk to my friends about it, even when they beg me to let them in, I'm just afraid if I pour the fears I have out they'll end up with them and being only 20 years old I don't want to trouble any of them with this when they still have years til they think about it. But I would try to get up, get a drink of water, turn on the tv or something next time you get a panic attack, It will pass quicker, I can now get though one in 3 minutes. I hope that helps you.