Everyone else is right. Try to line something new up first. But I was once in the position of quitting without something lined up, and the decider for me was that if I didn’t quit, I was likely to actually take my own life. It’s a matter of perspective at that point, and clearly, surviving was the better option.
Many depressed/suicidal folks often do give themselves to a cause or calling. Depression isn’t just the episodic spiral you see portrayed as depression, it’s also the hard fought days where only you can see your struggle. Along with therapy, exercise, and medication, “faking it til you make it” is the treatment plan, allowing yourself the freedom to try to function and feel better. And from experience, living for others is one of the easiest ways to push yourself to make an effort.
Unless you mean “dedicate their life to a random cause” as in “at least take someone awful with you”. That’s generally frowned upon advice, but I definitely understand the sentiment more than I wish.