Messenger of Allah ﷺ said," None of you should long for death because of a calamity that had befallen him, and if he cannot, but long for death, then he should say, 'O Allah! Let me live as long as life is better for me, and take my life if death is better for me.' " (Using translation from Bukhārī 6351)
قَالَ رَسُولُ اللهِ ﷺ أَلَا لَا يَتَمَنَّى أَحَدٌ الْمَوْتَ لِضُرٍّ نَزَلَ بِهِ فَإِنْ كَانَ لَا بُدَّ مُتَمَنِّيًا الْمَوْتَ فَلْيَقُلِ اللهُمَّ أَحْيِنِي مَا كَانَتِ الْحَيَاةُ خَيْرًا لِي وَتَوَفَّنِي إِذَا كَانَتِ الْوَفَاةُ خَيْرًا لِي