The Messenger of Allah ﷺ said, "When one of you goes to his bed, let him dust off his bedding with the inner edge of his garment, for he does not know what may have come upon it after he left. Then let him lie down on his right side and say, 'In Your name, my Lord, I lay down my side, and by Your power I raise it up. If You take my soul, have mercy on it, and if You release it, protect it with that by which You protect Your righteous servants.'"
حدثنا أحمد بن يونس حدثنا زهير حدثنا عبيد الله بن عمر عن سعيد بن أبي سعيد المقبري عن أبيه
قال رسول الله ﷺ إذا أوى أحدكم إلى فراشه فلينفض فراشه بداخلة إزاره فإنه لا يدري ما خلفه عليه ثم ليضطجع على شقه الأيمن ثم ليقل باسمك ربي وضعت جنبي وبك أرفعه إن أمسكت نفسي فارحمها وإن أرسلتها فاحفظها بما تحفظ به عبادك الصالحين
Bukhari narrated it in the Book of Supplications, Chapter 13, Hadith 6320, from Ahmad bin Yunus, and Muslim narrated it in the Book of Remembrance and Supplication, Chapter on Supplication upon Sleeping, Hadith 2714, from the hadith of Ubaydullah bin Umar, through him.