Suicide is haram; see e.g. Qur'an 4:29 (do not kill yourselves [or one another]) and What does Islam say about suicide? and Is suicide forbidden in the Qur'an?. However, while suicide is often pictured as a fairly short process, the reality may be blurrier:
- Try to kill oneself.
- Don't immediately succeed, but irreparably damage one's body.
- Subsequently die from the damage.
E.g. if someone drank poison, it may take hours to years before it resulted in the person's death.
When suicide is not immediate, it may be possible to sincerely repent to Allah before inevitably dying from suicide.
Question: Is it possible to repent from suicide?
While forgiveness is mentioned in the Qur'an Qur'an 39:53 (Indeed, Allah forgives all sins.), ahadith such as Sahih al-Bukhari 1363, 1364 (My slave has caused death on himself hurriedly, so I forbid Paradise for him) indicate a prolonged punishment for suicide.