It sounds a lot to me like you're talking about rather intense anxiety. Do you think that might have something to do with it?
If so, there ARE anxiety medications out there that can "take the edge off" those thoughts that just refuse to go away. Your mileage may vary though, because those kind of dull everything, not just anxiety. It made me feel like a robot, and I hated that. But that's a good solution for some people.
Without medication, it still is possible to break those overwhelming thought patterns. For me, it's usually some form of meditation. It is, however, very very difficult before you figure out the method that works best for you, especially when you're in the middle of an episode. The hardest part about it is to realize that nothing seems to work within the first few minutes, so you really have to keep trying at it.
Hopefully this is at least some help. I wish you the best.