The Prophet ﷺ said, "None of you should wish for death because of some harm that has befallen him. If he must do so, let him say, 'O Allah, keep me alive as long as life is better for me, and take me when death is better for me.'"
حدثنا آدم حدثنا شعبة حدثنا ثابت البناني
النبي ﷺ لا يتمنين أحدكم الموت من ضر أصابه فإن كان لا بد فاعلا فليقل اللهم أحيني ما كانت الحياة خيرا لي وتوفني إذا كانت الوفاة خيرا لي