Narrated Anas Bin Malik: The Prophet, pbuh, 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 God! Keep me alive as long as life is good for me, and let me die if death is better for me.”

Sahih Al-Bukhari – OB Vol. 7: 575