Anas (May Allah be pleased with him) reported that: The Messenger of Allah (Sallallahu álayhi wa sallam) said, “Let not one of you wish for death because of a misfortune which befalls him. If he cannot help doing so, he should say: ‘O Allah, keep me alive as long as You know that life is better for me, and make me die when death is better for me”.
[Al-Bukhari and Muslim]
This hadith indicates that there is prohibition in hoping for death or making supplication with tongue or in the heart as misfortune could be good for a believer. He should supplicate to Allah to grant him patience in overcoming the misfortune. If a person wish for death, death could be a evil thing for him as he does not know and only Allah knows. A man may die only to seek punishment.
Those who kill themselves will depart to a more severe torture in hearafter. The one who kills himself will be tortured by the tools that he used to kill himself. He will be tortured in hellfire as mentioned in a hadith of Prophet [Sallallahu álayhi wa sallam]. If he kills himself with a iron knife, he will kill himself with same iron knife in hellfire. The same would apply to jumping down or taking poison.
Prophet [Sallallahu álayhi wa sallam] always gave alternatives if there is one as he mentioned the alternative dua to make and it is also the way of Qur’an.
From Abu Sa’id and Abu Hurayrah: A man employed by the Prophet [Sallallahu álayhi wa sallam], peace be on him, in Khaybar brought for him janib [dates of very fine quality]. Upon the Prophet’s asking him whether all the dates of Khaybar were such, the man replied that this was not the case and added that “they exchanged a sa [a measure] of this kind for two or three [of the other kind]”. The Prophet, peace be on him, replied, “Do not do so. Sell [the lower quality dates] for dirhams and then use the dirhams to buy janib. [When dates are exchanged against dates] they should be equal in weight.” (Bukhari)
In the above case too, Prophet [Sallallahu álayhi wa sallam] pointed to an alternative.
In the case of alternative dua which the Prophet [Sallallahu álayhi wa sallam] taught us to make when one cannot himself in the face of misfortune, the person resigns himself to Allah as Allah knows but he does not.
“Say: None in the heavens or on earth, except Allah, knows what is hidden: nor can they perceive when they shall be raised up (for Judgment).” [Surah An Naml:65]
“Nor does any one know what it is that he will earn tomorrow: Nor does any one know in what land he is to die. Verily with Allah is full knowledge and He is acquainted (with all things).” [Surah Luqman: 34]
When a person makes dua to extend the life of someone, he should ask Allah to make him live longer in Allah’s obedience.
Maryam bin Imran [Alayhas Salam] wished to die, how could it be? There are two reasons to explain that and the first possible reason could be that their sharia was different.
“She cried (in her anguish): “Ah! would that I had died before this! would that I had been a thing forgotten and out of sight!”” [Surah Maryam: 23]
The second reason we could say is that she did not wish to die. She wished to die without being in a fitnah even if it mean she would stay 1000 years. This is like the saying of Yusuf [Alayhis salam] in:
“..Take Thou my soul (at death) as one submitting to Thy will (as a Muslim), and unite me with the righteous.” [Surah Yusuf: 101]
There is no harm in the above dua. One should make a distinction between a person wishing to die because of constraints and a person wishing to die with a quality pleasing to Allah. One who wishes death because of misfortune is not patient. This is forbidden.
The prophet [Sallallahu álayhi wa sallam] said:
“How amazing is the affair of the believer. Everything is good for him – and that is for no one but the believer: If good times come his way he is thankful and that is good for him, and if hardship comes his way he is patient and that is good for him.”
Explanation of hadith is taken from Dr Saleh as Saleh