That's a tough concept. If possible, you can find another job before quitting the current job, but when you do find another, make sure you have a notice of you quitting the current one that you're having issue with. If it's with mental health, it's important, but if you just hate it, then it would look really bad.
I spoke to someone few weeks ago about this. I personally wouldn’t quit before I found another job. Being broke is worse. And then comes responsibilities etc