Imam ibn Al-Qayyim said:
"In general, refraining from what causes punishment in the grave is the best way to avoid being punished. A person must sit for a while before he goes to bed and hold himself accountable for what he gained during that day and what he lost, then renew his sincere repentance to Allah and sleep after having repented, and when he wakes up, be determined not to commit the same sins again. He should do this every night; if he dies that night he would die after having repented, and if he wakes up, he would wake up happy because he was given a respite and given a chance to strive hard in good deeds to make up for what he missed out on. There is nothing better or more beneficial than such a way of going to sleep, especially if he follows this accountability with mentioning Allah and follows the recommendations of Sunnah (Prophetic tradition) on how to go to sleep and supplicate until he falls asleep. The one whom Allah wills good for, He will guide him to doing so."
The Prophet informed us about some means which will rescue us from punishment in the grave:
· Salmaan Al-Faarisi narrated that the Prophet said: “Ribaat (guarding the front lines of the Muslim army) for one day is better (in reward) than fasting for a full month and praying during its nights; and the one who dies while in that position will have the reward of the deeds he was doing to continue (until The Day of Resurrection) and he will be saved from the punishment of the grave." [Muslim]
· One of the Companions of the Prophet asked the Prophet "How come all the people are tried in their graves except for the martyrs?" He replied: “The flashing of the swords over their heads is enough of a trial.” [An-Nasaa’i]
· Al-Miqdaad ibn Ma'd Yakrib narrated that the Prophet said: “The martyr has seven qualities which Allah grants him: he will be forgiven with the first drop of his blood, he will see his seat in Paradise, he will be rescued from the punishment of the grave, he will be rescued from the Great Horror (on the Day of Resurrection), he will wear a (special) garment of faith, he will marry seventy two women of Paradise, and he will be allowed to intercede for seventy of his family.” [Ibn Maajah].In another narration he said: “The crown of dignity will be placed on his (i.e., the martyr's) head, each corundum (of which) is better than this world and all what it contains; he will have seventy two wives from the ladies of Paradise, and he will be allowed to intercede for seventy of his family.” [At-Tirmithi]
· Abu Hurayrah narrated that the Prophet said: “There is a chapter in the Quran (Al-Mulk) that has thirty verses; it will intercede for the one who continuously recites it, until he is forgiven.” [An-Nasaa’i and Ibn Maajah]. This Hadeeth (narration), and others which carry the same meaning, prove that those who regularly recite chapter Al-Mulk and apply what is in it, will be rescued from the punishment in the grave.
· The Prophet said: “The one who dies as a result of a stomach ailment will not be punished in his grave.” [At-Tirmithi]. This reward will be for those who do not despair upon their sickness, but rather persevere through it and hope for the reward from Allah The Almight.
· The Prophet said: “Allah will protect from the trials of the grave, any Muslim who dies on a Friday -- day or night.” [Ahmad]
· Fulfilling piety, Allah The Almighty Says what means: {“Verily, those who say: Our Lord is (only) Allah, and thereafter stand firm (on the Islamic Monotheism), on them shall be no fear, nor shall they grieve.”} [Quran, 46: 13]