The Quran tells believers not to kill themselves (the Arabic wording can also mean not to kill one another) and adds that Allah is ever Merciful to them. The prohibition shows how precious life is, and it is not contempt for those who suffer. The Prophet Muhammad ﷺ also gave very stern warnings against taking one's own life, and they are not to be played down. Islam does not treat pain as weakness: he taught that nothing strikes a believer of tiredness, worry or grief, even a thorn, except that Allah removes sins by it. The Quran promises that with hardship comes ease. The feeling that nothing will ever change is something deep pain tells people, and it is not the truth.
For those grieving someone who died this way, the Muslim belief is that judgment belongs to Allah, the Most Merciful and Most Just, who knows what the person was carrying. Scholars of the mainstream Sunni schools understand the warnings as showing how grave the act is, not as a verdict on any individual, and hold that a believer who dies in a major sin remains under Allah's will. The Prophet ﷺ taught that whoever of his community dies without associating anything with Allah enters Paradise. Most scholars hold that the funeral prayer is offered for such a person, and family and friends may ask forgiveness for them and give charity on their behalf: a man once asked whether his mother, who had died suddenly, would be rewarded if he gave charity for her, and the Prophet ﷺ said yes. Many contemporary scholars also note that severe mental illness can reduce a person's responsibility.
If you are the one struggling, please do not carry it alone. Tell someone you trust, see a doctor or counsellor, and contact your local emergency number or a crisis line (in the United States you can call or text 988, and findahelpline.com lists services in many countries). Stay near other people, and keep away from anything you could use to hurt yourself. Prayer, the Quran and supplication can be a real comfort and go together with medical help, but they should not replace it. Allah's mercy is wider than your darkest hour, and many people who once felt this way found relief when they got the right help.