And do not kill yourselves [or one another]. Indeed, Allah is to you ever Merciful[Quran 4:29]
Suicide is something that is considered a sin in many religions, Islam included. In Islam thinking about committing an action is not the same as carrying out that action
“Allah says to the angels: If my servant intends a bad deed, do not record it unless he does it”
However the concept of sin only applies to those who are mentally well. If one is in a state of mind in which they are unable to think clearly, as can be said for a person who is mentally distressed and thinking about suicide, then Islam does not expect anything of them. They are not thought to be accountable for their thoughts or actions and no act of worship, such as praying and fasting, is obligatory on them.
“The pen is lifted from the sleeper until he awakes, the child until he grows up, and the insane until he regains his senses.”
Asking someone if they have had thoughts about ending their life will not put the idea into the head, if you think someone is considering ending their life, then you should ask them directly and help them to reach out for the support they need.
Although act of ending one’s life is not allowed in Islam, it is not something that means they are no longer Muslim, supplications can still be made for the person. It is still an obligation on the Muslim community to provide them with an Islamic funeral prayer and burial.