Everyone is different but I slowly started to filter out negative habits and emotional traits, forcing myself to eat multiple meals a day, forcing myself to go outside and interact with people face to face, eat clean and exercise, your brain is an organ like any other you have to be healthy if you want it to function properly. Also, mentally, I found new purpose in political organizing (for you this can be any passion) and despite a pretty harsh atheist worldview my passion gave me a lot of hope for the future. Therapy can also help but I'm pretty stubborn and sarcastic so if I need to get right mentally, nothing works better than for me to stop bad habits and meditate on what I really want from life.
I also found inspiration from people who also overcame a fear of death and reading about cosmology.
Mortality by Christopher Hitchens
Just my 2 cents, I'm also a massive weirdo so take this with a grain of salt.