Sayyiduna Anas bin Malik (may Allah be pleased with him) narrates: The Prophet Muhammad (peace and blessings be upon him) said: "None of you should ever wish for death because of any calamity that befalls him. If he must wish for it, then let him say: O Allah! Keep me alive as long as life is better for me, and cause me to die when death is better for me."
Hadith Referenceصحیح ابن حبان / كتاب الجنائز وما يتعلق بها مقدما أو مؤخرا / 3001
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح - «الإرواء» (683): ق.فضيلة الشيخ العلّامة شُعيب الأرناؤوطإسناده صحيح على شرط البخاري