I've felt like that, more times than I care to want to remember. While there's no way I can think of that's some magical way of snapping instantaneously into a state of mind that rebukes such thoughts, what I can say, is this...
A noun.
Some person you care about, or who you know that cares about you, or perhaps even a person you haven't yet met. For me, it was, at some point, each of these that kept me going. I wanted to be done, but I didn't want to be selfish about it. Heck, even my dog has saved me from me, and I love him far too much to give up on him (the thought of him always contributes to pulling me back).
Some place you've been before that means a lot to you, or some place you've never been, that you dream about visiting. Create a Bucket List. I'm not religious anymore, though I was raised to be, so I do understand the religious convictions of my parents, as well as billions of others around the globe. I don't judge, but what I do allow myself to do, is imagine the possibility that we really only do get one spin - one singular time at life. It's one of the reasons I decided to start a travel blog, last year. It kept me going, thinking about the places I'd like to see and the experiences I'd like to have, and to help others learn about those experiences, who may be feeling like I did.
Some thing you'd like to do, or perhaps some thing you already do, that brings you joy. Perhaps find a new thing you might like to do. I found some things on Udemy that have become a passion. Get on Audible and find some good books. I don't know of any good alien stories, except for this one trilogy in which there were 3 aliens (however, they were humans) to an alien population. They were 3 athletic acrobat women who worked at a circus. They were abducted by aliens, and they used their acrobatic talents to become really great fighters and skilled warriors. There are a ton of really great audiobooks on there. I used to just get on the road and drive - no destination. Just the open road and Audible. These, too, have saved me.
I don't know what's happening in your life, but pain is temporary. It only becomes permanent once you quit - in business, or investing, or otherwise. Find a reason to give yourself another chance. Nobody else can do this for you. It's a decision that only you can decide. Choose you, or choose someone, someplace, or something worth holding on to.
Try to see beyond the negativity.