Recently I lost my job as a lecturer under quite disagreeable circumstances which will have me leave academia for good. I got a PhD which is worthless outside of university and this job virtually has been my life as long as I can think, although I have also been struggling at times due to mental health problems, which have since peaked.   
Now there is nothing positive to keep me afloat anymore.

I am a trans man and got no girlfriend and no kids (though I would have loved to have a family of my own), and no friends to talk to. Health-wise, I have strong sociophobia, anxiety and severe, chronic treatment-resistant depression (all psychiatrist's diagnoses). Neither meds nor therapy nor my own efforts, like mindfulness or sports, have led to any long-term improvement. 

After my recent experiences, my, always low, self-esteem is way below zero, as is my confidence in anything I might (have to) undertake.   
The only reason I cannot give up yet is that I have to care for my elderly parents (not wholly devoid of conflict either, as they are also depressed, but I love and want to support them, so this part is non-negotiable). At the moment I am completely certain that I will end it as soon as they don't need me anymore.

With my job, apart from low-level financial security, I have most of all lost my intellectual and emotional home and "safe space" and I cannot find anything worth living or hope for. In my future, I can only perceive loss (esp. family), failure (professional and general) and loneliness.  
When I was better, I enjoyed being in nature, biking, making and listening to music, getting a bit into coding, playing computer games, and writing, especially fantasy (all of this alone, due to sociophobia, but still I was doing something).

Now I am hardly able to leave my flat or talk to someone, nor do I want to, while, at the same time, the loneliness is unbearable.

I feel completely unwanted and thoroughly unfit for any kind of life, having no purpose, nothing "to offer the world" - a waste of oxygen and space.   
Even if there were things that I like(d), I am too old to do them now, or even learn them properly for a living (as in anything IT-related): unable to compete with people who are so much younger, more competent and eager, better educated and stress-resistant. It is all too late for that.  
And just working some job merely to prolong a life I do not want holds no attraction whatsoever.

Any ideas how to cope with this? 

Whoever has read so far, thank you very much for your time