We came in to visit Khabab, who had been cauterized seven times on his stomach. He said, "Were it not that the Messenger of Allah ﷺ forbade us to pray for death, I would have prayed for it."
دخلنا على خباب وقد اكتوى سبع كيات في بطنه فقال: لو ما أن رسول الله ﷺ نهانا أن ندعو بالموت لدعوت به.
Bukhari narrated it in the Book of Supplications (6349, 6345), and Muslim in the Book of Remembrance (2681), both through Ismail bin Abu Khalid, from Qays bin Abu Hazim, who mentioned it. The wording given here is Muslim's.