حَدَّثَنَا عِمْرَانُ بْنُ مُوسَى اللَّيْثِيُّ، حَدَّثَنَا عَبْدُ الْوَارِثِ بْنُ سَعِيدٍ، حَدَّثَنَا عَبْدُ الْعَزِيزِ بْنُ صُهَيْبٍ، عَنْ أَنَسٍ، قَالَ قَالَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ ‏:‏ ‏"‏ لاَ يَتَمَنَّى أَحَدُكُمُ الْمَوْتَ لِضُرٍّ نَزَلَ بِهِ فَإِنْ كَانَ لاَ بُدَّ مُتَمَنِّيًا الْمَوْتَ فَلْيَقُلِ ‏:‏ اللَّهُمَّ أَحْيِنِي مَا كَانَتِ الْحَيَاةُ خَيْرًا لِي وَتَوَفَّنِي إِذَا كَانَتِ الْوَفَاةُ خَيْرًا لِي ‏"‏ ‏.‏

4265 It wasnarrated from Anas that the Messenger of Allah (PBUH) said: “None ofyou should wish for death because of some harm that befallshim. Ifhe must wish for death, let him say: ‘O Allah, keep me alivesolong as living is good for me and cause me to die when death isgoodfor me.’” Translation Not Available

Book Ref: Sunan Ibn Majah Book 37 Hadith 4265
Web Ref:  Sunan Ibn Majah Vol 5 Book 37 Hadith 4265