“None of you should wish for death because of some harm that befalls him. If he must wish for death, let him say: ‘O Allah, keep me alive so long as living is good for me and cause me to die when death is good for me.’” (Using translation from Ibn Mājah 4265)
عَنِ النَّبِيِّ ﷺ قَالَ لَا يَتَمَنَّيَنَّ أَحَدُكُمُ الْمَوْتَ لِضُرِّ نَزَلَ بِهِ فَإِنْ كَانَ لَا بُدَّ فَاعِلًا فَلْيَقُلِ اللهُمَّ أَحْيِنِي مَا كَانَتِ الْحَيَاةُ خَيْرًا لِي وَتَوَفَّنِي إِذَا كَانَتِ الْوَفَاةُ خَيْرًا لِي