Yeah. I've gotten so lonely at one time in my life that it was having tangible, physiological effects on me.
Thankfully, I'm past that point in my life and hoping it stays that way.
What I can say about this is that you only lose when you give up. So don't. If you're feeling like nothing is working then it's time to think about doing things differently. If you feel as though it goes against who you are then maybe that's exactly the problem. Think of it this way: we are all unique and in a sense, that means we are all mutations. But not all mutations are viable. This is what nature is and from it we are not exempt. But you can become a different mutation -- a viable mutation -- by changing yourself, by working on yourself, by adapting yourself. If you're at a point where you'd rather be dead then what's really the point of staying as you are? If your current identity* wants to cease to exist then kill that identity instead of your body. Identities can be replaced. Dead bodies cannot. The mind is a terrible thing to waste but the body even more so in this case.
This is exactly what I've done and I regret nothing. All I can warn is that things could have gone terribly wrong in the process and that nothing was guaranteed but I took that leap of faith.
*An important caveat here. By "identity" I mean all the ideas by which you define yourself as. I'm only talking about character traits and your outlook on life -- "the soul", in a sense. Strictly excluded are fixed physical traits such as race and sexual orientation -- things that cannot be changed.