Sahih Muslim · Hadith 6990
The Book Pertaining to the Remembrance of Allah; Supplication; Repentance and Seeking Forgiveness - كتاب الذكر والدعاء والتوبة والاستغفار
حدثنا زهير بن حرب، حدثنا إسماعيل، - يعني ابن علية - عن عبد العزيز، عن أنس، قال قال رسول الله صلى الله عليه وسلم " لا يتمنين أحدكم الموت لضر نزل به فإن كان لا بد متمنيا فليقل اللهم أحيني ما كانت الحياة خيرا لي وتوفني إذا كانت الوفاة خيرا لي " .
Anas (b. Malik) reported Allah's Messenger (may peace be upon him) as saying. None of you should make a request for death because of the trouble in which he is involved, but if there is no other help to it, then say: O Allah, keep me alive as long as there is goodness in life for me and bring death to me when there is goodness in death for me.
Gradings are classical jarḥ-wa-taʿdīl, name-matched to a rijāl index (not individually re-verified).