Sayyiduna Anas bin Malik (may Allah be pleased with him) narrates: The Prophet Muhammad (peace and blessings be upon him) said: "No person should ever wish for death because of any hardship that befalls him, rather he should say: O Allah! Keep me alive as long as life is better for me, and give me death when death is better for me."
Hadith Referenceصحیح ابن حبان / كتاب الرقائق / 969
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح: ق - انظر ما قبله.فضيلة الشيخ العلّامة شُعيب الأرناؤوطإسناده صحيح على شرط مسلم، رجاله ثقات رجال الشيخين غير يحيى المقابري، فمن رجال مسلم.