Ive used mindfulness. It took me a long while and a lot of practice.
It's about being able to step back from the thought and just watch it pass by.
I often imagine my thoughts on a train that's passing me by. Without giving it power or managing your emotions as it does. Also managing your breathing.
I still struggle as there isn't a fix. But it's about making it more manageable.
If panic sets in, I turn to managing the physical reaction of fight or flight. Aiming go bring down my breathing rate, heart rate, shaking etc. Usually using breathing techniques.
I hope this might be helpful.