I'm not entirely sure how to stop it, but my own two goals are self-improvement and forming new human connections. I think that a lost human connection leaves us with a kind of emptiness inside, and we see that emptiness and go back over and reinforce the neural circuits in the brain associated with grief, longing, anger, sadness, and so on. I think something has to jolt the system out of the cycle it's caught in, and if what we lost was an incredibly important human connection, then the best thing we can do is try to find new important human connections. When we spend time with new people in a good way it will keep our mind off the one we lost, and we won't feel that normal nagging emptiness that is there when we try to distract ourselves in other ways (television, games, etc.).
Just to illustrate what I mean, when I lost my important person I also left a group of several good friends of mine. I still haven't formed new human connections, and so that's why I'm still here 2.5 years later occasionally writing letters I never send, crying at night, etc. Another friend of mine who has mental illness lost an important person in a similar manner to how it happened to me: suddenly, and unexpectedly. We could see that she was experiencing things similar to what I had experienced, especially with suicidality and emotional pain. She improved a lot within months though because she made new friends through meetups and social apps.
At the end of the day, everyone is different. I'm not sure what will work best for you, but I think going to therapy, building a support system, and forming new human connections would be likely to. Also I'm really sorry for what you're going through, and I hope you can perhaps find a way to self-soothe and cope.