The Messenger of Allah ﷺ said, "When one of you comes to his bed, let him take the inner edge of his lower garment and dust off his bed with it, 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 leave I raise it. If You take my soul, have mercy on it, and if You send it back, protect it as You protect Your righteous servants.'"
حدثنا يحيى بن سعيد الأموي قال حدثنا عبيد الله بن عمر بن حفص بن عاصم عن سعيد بن أبي سعيد عن أبيه
قال رسول الله ﷺ إذا أتى أحدكم فراشه فلينزع داخلة إزاره ثم لينفض بها فراشه فإنه لا يدري ما حدث عليه بعده ثم ليضطجع على جنبه الأيمن ثم ليقل باسمك ربي وضعت جنبي وبك أرفعه إن أمسكت نفسي فارحمها وإن أرسلتها فاحفظها بما حفظت به عبادك الصالحين
Its isnad is sahih. Bukhari related something similar 8/87 in the Book of Supplications, in the chapter on seeking refuge and recitation, as did Muslim 4/2084 no. 2714 in the Book of Remembrance, on what one says upon sleeping, and Abu Dawud 4/312 no. 5051, and Tirmidhi 5/470 no. 3396, who said, hasan sahih gharib.