So there were two key developments that helped me personally.
The first was a unified theory of righteousness, manifested in five commitments I made to myself. They are commitments that I view as essential to a good or heroic life, they are interdependent and when they are in conflict they require wisdom to resolve the tension. They are commitments of love, honesty, ambition, compassion, and humility. So the idea that I had stable commitments started to anchor me: I was not totally worthless because I had understood the basic axioms for being heroic. So this is a core environmental change. I could go on and on about what each of these mean but it is perhaps not the right context or time for that just here.
The second major change was an adaptive change in crisis moments. I have a strange religious history where I started Catholic, became a fundamentalist, became an atheist, became a Buddhist, became a mystic Christian again. Somewhere in the atheist phase after fundamentalism I had started learning about Buddhism as part of a general interest in world religions and their models of heroism but before I had really started meeting Tibetan Buddhists in person. This introduced me to meditation, but that was not quite what I use: meditation is something of a constant attention-strengthening exercise, this is more of an acute stress response. The idea is that I simply try to sit still in the middle of these swirling negative emotions. My problem is that each negative thought causes, on average, more than one negative thought: this change in what I am paying attention to and how I am organizing my activity, takes that number less than 1. I would not say that it is fully zero. But the point is, that then my negative emotions behave more like others', they multiply a little bit but eventually peter out. So just by finding that eye of the storm, I can eventually gain control of my mind again.