Suicide, attempted suicide and threats of suicide are all symptoms of depression. And I agree with that a person who commits, attempts or threatens suicide just wants the pain to stop.
Can you imagine a life so depressed and painful that you would rather not wake up than to hurt like that? And the fact that there is no physical pain just makes it worse, makes you feel lousier, makes it harder to see that there is any other way out. If your leg hurts, you expect that the doctor will fix it. But when the pain is a psychic pain, it is harder to see that it will ever get better.
What causes the pain is usually a mixture of emotions. Depression is the primary, often there is also a supporting emotion. Frustration, stress, guilt, worry and/or grief will sometimes be mixed up in it also.
Been there, done that.