(17) باب مَا يَقُولُ عِنْدَ النَّوْمِ وَأَخْذِ الْمَضْجَعِ
Abdullah b. 'Umar commanded a person that as he went to bed, he should say:
" O Allah, Thou created my being and it is for Thee to take it to its ultimate goal. And its death and life is due to Thee, and if Thou givest it life, safeguard it; and if Thou bringst death, grant it pardon. O Allah, I beg of Thee safety." A person said to him: Did you hear it from Umar? Thereupon he said: (I have heard from one) who is better than Umar, viz. from Allah's Messenger (ﷺ). Ibn Nafi, reported this on the authority of Abdullah b. Harith but he did not make mention of this" that he heard it himself".
Reference: Sahih Muslim 2712
In-book reference: Book 48, Hadith 81
USC-MSA web (English) reference(deprecated numbering scheme): Book 35, Hadith 6550