Language:
كتاب المرضى
75  
Patients
(19)
Chapter: The patient's wish for death
(19)
باب تَمَنِّي الْمَرِيضِ الْمَوْتَ
Sahih al-Bukhari 5673

Narrated Abu Huraira:

I heard Allah's Messenger (ﷺ) saying, "The good deeds of any person will not make him enter Paradise." (i.e., None can enter Paradise through his good deeds.) They (the Prophet's companions) said, 'Not even you, O Allah's Messenger (ﷺ)?' He said, "Not even myself, unless Allah bestows His favor and mercy on me." So be moderate in your religious deeds and do the deeds that are within your ability: and none of you should wish for death, for if he is a good doer, he may increase his good deeds, and if he is an evil doer, he may repent to Allah."

حَدَّثَنَا أَبُو الْيَمَانِ، أَخْبَرَنَا شُعَيْبٌ، عَنِ الزُّهْرِيِّ، قَالَ أَخْبَرَنِي أَبُو عُبَيْدٍ، مَوْلَى عَبْدِ الرَّحْمَنِ بْنِ عَوْفٍ أَنَّ أَبَا هُرَيْرَةَ، قَالَ سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏"‏ لَنْ يُدْخِلَ أَحَدًا عَمَلُهُ الْجَنَّةَ ‏"‏‏.‏ قَالُوا وَلاَ أَنْتَ يَا رَسُولَ اللَّهِ قَالَ ‏"‏ لاَ، وَلاَ أَنَا إِلاَّ أَنْ يَتَغَمَّدَنِي اللَّهُ بِفَضْلٍ وَرَحْمَةٍ فَسَدِّدُوا وَقَارِبُوا وَلاَ يَتَمَنَّيَنَّ أَحَدُكُمُ الْمَوْتَ إِمَّا مُحْسِنًا فَلَعَلَّهُ أَنْ يَزْدَادَ خَيْرًا، وَإِمَّا مُسِيئًا فَلَعَلَّهُ أَنْ يَسْتَعْتِبَ ‏"‏‏.‏
Reference : Sahih al-Bukhari 5673
In-book reference : Book 75, Hadith 33
USC-MSA web (English) reference : Vol. 7, Book 70, Hadith 577
  (deprecated numbering scheme)