Sunnah.com : Book 1, Hadith 585
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
وعن أنس رضي الله عنه قال: قال رسول الله صلى الله عليه وسلم: “لا يتمنين أحدكم الموت لضر أصابه فإن كان لابد فاعلاً، فليقل: اللهم أحينى ما كانت الحياة خيراً لى، وتوفنى إذا كانت الوفاة خيراً لى” ((متفق عليه)).
Anas bin Malik (May Allah be pleased with him) reported:
Messenger of Allah (ﷺ) said, "Let none of you wish for death on account of an affliction that befalls him. If he has no alternative, let him pray: 'Allahumma ahyine ma kanatil-hayatu khairan li, wa tawaffani idha kanatil-wafatu khairan li (O Allah! Give my life so long as the life is good for me, and take away my life if death is good for me)'." [Al-Bukhari and Muslim].
Full reference and source
Sunnah.com : Book 1, Hadith 585 Arabic/English book : Book 1, Hadith 586
View source on Sunnah.com (opens in a new tab)