كتاب الذكر والدعاء والتوبة والاستغفار
48  
The Book Pertaining to the Remembrance of Allah, Supplication, Repentance and Seeking Forgiveness
(4)
Chapter: It Is Disliked To Wish For Death Because Of Some Harm That Has Befallen One
(4)
باب كَرَاهَةِ تَمَنِّي الْمَوْتِ لِضُرٍّ نَزَلَ بِهِ
Sahih Muslim 2680 c

Nadr b. Anas reported, as when Anas was alive, that he said:

Had Allah's Messenger (ﷺ) not stated this.." None should make a request for death," I would have definitely done that.
حَدَّثَنِي حَامِدُ بْنُ عُمَرَ، حَدَّثَنَا عَبْدُ الْوَاحِدِ، حَدَّثَنَا عَاصِمٌ، عَنِ النَّضْرِ بْنِ أَنَسٍ، وَأَنَسٌ، يَوْمَئِذٍ حَىٌّ قَالَ أَنَسٌ لَوْلاَ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ لاَ يَتَمَنَّيَنَّ أَحَدُكُمُ الْمَوْتَ ‏"‏ ‏.‏ لَتَمَنَّيْتُهُ ‏.‏
Reference : Sahih Muslim 2680c
In-book reference : Book 48, Hadith 12
USC-MSA web (English) reference : Book 35, Hadith 6482
  (deprecated numbering scheme)