How did I get out? I knew for sure that if this ends, then everything turns for the better. So started to to think about the life after the thesis.
First went to the uni counsellor and sought therapy/help. Requested a refund due to mental health issues (luckily one year granted).
I knew I needed one final leg of work to be done to finish. Tried to write a few words every day and possibly created the worst draft of a thesis. Sent it to the supervisor and convinced them to set a date for the defence. The date was two days before my visa expired.
Did a terrible defence which they reluctantly agreed to give me the accepting grade. Tried to finalise the graduation stuff that day to make it to visa appointment the next day. Missed that so had to postpone but eventually turned out fine.
Directly went to a company I used to work part-time and asked them to hire me full-time. Requested a month of salary in advance to be able to pay the rent.
Started working immediately and paying off my debt. Life started to get better. Moved out of that town after a year and didn't step on the campus for the next 7 years.
Not sure if there's much for you in this story. But the only thing that kept me going was the certainty I had that once this thesis is over, my life will change for the better. Crawl your way out of it whatever it takes. Quitting was not an option for me (legal/visa reasons). I understand you might not want to quit a PhD as well. So just try to finish it with bare minimum quality. Don't shoot for the stars and if you're high on some achievement one day don't let that change the goal of only finishing it.
Wishing you the best and rest assured, better days come after this.