I think one of the best ways to stop yourself from relapsing into unwanted habits is to recognize that you’re having those habits to begin with. Sometimes it can be hard to admit, but that recognition can get you to the next steps of actually stopping or shrinking those habits down to something manageable.
I used to be incredibly afraid of meeting new people or going to social gatherings with people I didn’t know. I would make up reasons why I couldn’t go, because I felt like it was too uncomfortable. I’d sometimes imagine being introduced to a huge crowd of people, too crowded to move, and them not caring about me being there at all. So I’d shut myself inside somewhere and feel like I solved that problem. Except that I’d get an overwhelming feeling of anxiety next time I had to make a decision to go out or stay in.
One of the ways of helping you recognize those habits is talking to a trusted friend or someone from your family. Someone who doesn’t pass judgement can be extremely important, so you can feel free to express your feelings on things. I ended up talking to my immediate family and some close friends about my fears over time, and it led me to try going to more social gatherings without so much anxiety.
Having those people around when you relapse into your previous behaviors can help too. Even if it’s not going to a proper ‘event’ to meet new people, I try to go outside for a walk to a new place - just to clear my head or see the world around me. I found that as long as I’m willing to talk about it to start addressing the problem, the sooner I can get past those anxieties.