Sayyiduna Anas bin Malik (may Allah be pleased with him) narrates about the Noble Prophet (peace and blessings be upon him): He said: No person should ever wish for death because of any hardship that befalls him. If he must do so, then 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صحیح ابن حبان / كتاب الرقائق / 968
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح - «أحكام الجنائز» (12): ق.فضيلة الشيخ العلّامة شُعيب الأرناؤوطإسناده صحيح، على شرط الشيخين. محمد: هو ابن جعفر المدني المعروف بغندر.