´It was narrated from 'Abdullah that:` whenever the Prophet (saas) went to his bed, he would put his hand - meaning his right hand - beneath his cheek then say: "Allahumma qini 'adhabaka yawm tab'athu - [or: tajma'u] - 'ibadaka (O Allah, save me from Your punishment on the Day when You resurrect - or gather - Your slaves)."
Explanation & Benefits
Maulana Ataullah Sajid
Benefits and Issues:
➊ Sleep reminds one of death. After which, one will rise to stand before Allah; therefore, it is appropriate to seek refuge from the punishment of the Day of Resurrection at the time of sleeping.
➋ The Messenger of Allah (sallallahu alayhi wa sallam) is the closest and most virtuous servant of Allah. For whom even the thought of punishment is not possible, yet he (sallallahu alayhi wa sallam) recited this supplication. This is so that servitude is acknowledged and to serve as an example for the believers.
➌ In the aforementioned hadith, it is not narrated how many times this supplication should be recited; however, in one narration of Abu Dawud, it is mentioned that the Messenger of Allah (sallallahu alayhi wa sallam) would recite this supplication three times. See: (Sunan Abi Dawud, Al-Adab, What to Say at the Time of Sleeping, Hadith: 5045)
Source: Commentary on Sunan Ibn Mājah by Mawlānā ‘Atā’ullāh Sājid, Page: 3877