Sahih al-Bukhari Book 75, Hadith 31
The Prophet (ﷺ) said, "None of you should wish for death because of a calamity befalling him; but if he
has to wish for death, he should say: "O Allah! Keep me alive as long as life is better for me, and let
me die if death is better for me.' "
My aunt took me to Allah's Messenger (ﷺ) and said, "O Allah's Messenger (ﷺ)! My nephew is- ill." The Prophet (ﷺ) touched my head with his hand and invoked Allah to bless me. He then performed ablution and I drank of the remaining water of his ablution and then stood behind his back and saw "Khatam An- Nubuwwa" (The Seal of Prophethood) between his shoulders like a button of a tent.
We went to pay a visit to Khabbab (who was sick) and he had been branded (cauterized) at seven places in his body. He said, "Our companions who died (during the lifetime of the Prophet) left (this world) without having their rewards reduced through enjoying the pleasures of this life, but we have got (so much) wealth that we find no way to spend It except on the construction of buildings Had the Prophet not forbidden us to wish for death, I would have wished for it.' We visited him for the second time while he was building a wall. He said, A Muslim is rewarded (in the Hereafter) for whatever he spends except for something that he spends on building."