There was a similar scenario during the life of the Holy Prophet
We were in the company of Allah’s Messenger
(Sahih al-Bukhari, Book 56, Hadith 268)sas in a battle, and he remarked about a man who claimed to be a Muslim, saying, “This man is from the people of the Hell Fire.” When the battle started, the man fought violently till he got wounded. Somebody said, “O Allah’s Messengersas ! The man whom you described as being from the people of the Hell Fire fought violently today and died.” The Prophetsas said, “He will go to the Hell Fire.” Some people were on the point of doubting (the truth of what the Prophet had said), while they were in this state, suddenly someone said that he was still alive but severely wounded. When night fell, he lost patience and committed suicide. The Prophetsas was informed of that, and he said, “Allah is Greater! I testify that I am Allah’s Slave and His Apostle.” Then he ordered Bilal to announce amongst the people: “None will enter Paradise but a Muslim, and Allah may support this religion even with a disobedient man.”
The Holy Prophet
So when the army files were arranged in rows (for the clash), ‘Amir’s sword was short and he aimed at the leg of a Jew to strike it, but the sharp blade of the sword returned to him and injured his own knee, and that caused him to die. When they returned from the battle, Allah’s Messenger
(Sahih al-Bukhari, Book 64, Hadith 236; Sahih Muslim, Book 32, Hadith 150)sas saw me (in a sad mood). He took my hand and said, “What is bothering you?” I replied, “Let my father and mother be sacrificed for you! The people say that the deeds of ‘Amir are lost.” The Prophetsas said, “Whoever says so, is mistaken, for ‘Amir has got a double reward.”
Only when the Holy Prophet
None of you should wish for death. If he is righteous, perhaps he may add to his good works, and if he is a sinner, possibly he may repent.
(Sahih al-Bukhari, Book 94, Hadith 10)
When a person despairs of Allah’s mercy and takes his own life, then in the hereafter the value of this life and the gravity of his mistake become apparent to him. This realization and regret itself can become a punishment, which has been described by the Holy Prophet sas:
Whoever commits suicide with something, will be punished with the same thing in the hell fire.
(Sahih al-Bukhari, Book 78, Hadith 132)