Indeed, the best way I have gotten out of bad trips were to remind myself that I took a substance and that it'll pass. Once I get myself to focus on that and keep it in mind, the trip at least becomes neutral but more often positive. Not immediately most times, but eventually for sure. Supportive friends really help a lot too.
I've had terrifying bad trips, even though I don't have emotional/mental turmoil and I'm pretty sure my mind state is strong and as secure as can be. I've been through some pretty crappy times but I've always been able to learn from them and take positives away from events that were completely negative. I've seen most who have gone through something similar either affect them negatively way past the trauma, or they simply ignore it until time heals it. I'll shed a tiny bit of light on a very personal trauma that I went through that included physical/emotional abuse, no help, my very first gf cheated on me even though I did everything right, had many people laughing and shit talking on said abuse and my gf cheating on me, got kicked out of my house (many times) and ended up sleeping in a parking lot those particular days for trying to stop the abuse. Not to mention we were poor and lived in a poor neighborhood at the time, which compounded on those family issues (as we all know severe financial difficulties can easily wreck a household)...all of which happened at the same time when I was only 16.
Yet, as I said, I don't have any emotional turmoil and I'm pretty much at peace with everything. That trauma made me strong mentally, and from then on I was able to easily get over anything that was less traumatizing than that. Whereas most others who suffered something similar either go on to wallow in their despair, not try to fix anything and do what they can, become abusers themselves, etc. Personally, I couldn't imagine abusing anyone and I never will, including my dog who I treat like a baby.
Anyway, sometimes I did suffer that feeling of total despair just like I felt during that trauma when I have a really bad trip. None of my visuals have ever been related to that, for whatever reason, but I've always been able to come out of it with it having absolutely no negative effect on my psyche and outlook. It's just simply not enough to break me because it was only the drug making me see and feel that way, and not actual real life where there's absolutely no escape from it and I'd have to deal with it anyway. When I turned it all around on my own and fixed what I could, that's when I had mentally grown the most by far. Ironically, I became more fun-loving and good hearted after that trauma. I don't really know why either.
Damn, I said too much...but yeah, though I've had terrifying visuals (including gory shit) on bad trips and those classic negative thought loops, when it's all said and done I easily get over it and don't let it negatively affect me at all. Simply by reminding myself that I'm just tripping and that it'll pass.