The Messenger of Allah ﷺ said, "None of you should ever wish for death. If he is a doer of good, he may live longer and increase in good, which is better for him. And if he is a wrongdoer, he may yet seek to make amends."
أخبرنا عمرو بن عثمان قال حدثنا بقية قال حدثني الزبيدي قال حدثني الزهري عن أبي عبيد مولى عبد الرحمن بن عوف أنه سمع
قال رسول الله ﷺ لا يتمنين أحدكم الموت إما محسنا فلعله أن يعيش يزداد خيرا وهو خير له وإما مسيئا فلعله أن يستعتب
Bukhari narrated it in the chapter "Illness Making a Patient Wish for Death," Hadith: 5673, from Zuhri's hadith through the same chain, and he stated explicitly that he heard it directly. It is also found in the Kubra, Hadith: 1945.Abu Ubayd is Saad bin Ubayd.