‘Ubaidallah b Khalid reported God’s messenger as saying, “Sudden death is an act of punishment out of anger.” Abu Dawud transmitted it.
Baihaqi in Shu'ab al-iman and Razin in his book made an addition, saying “An act of punishment out of anger for the infidel and a mercy for the believer.”
Anas said that the Prophet visited a young man who was dying and asked him how he was. He replied, “I am hoping in God, messenger of God, but I am afraid of my sins,” whereupon God's messenger said, “The two cannot come together in a man’s heart at such a time without God giving him what he hopes for and granting him security from what he fears.”
Tirmidhi and Ibn Majah transmitted it, Tirmidhi saying that this is a gharib tradition.
وَعَن عبد الله بن عَمْرو قَالَ ك قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «تُحْفَةُ الْمُؤْمِنِ الْمَوْتُ» . رَوَاهُ الْبَيْهَقِيُّ فِي شُعَبِ الْإِيمَان
‘Abdallah b. ‘Amr reported God’s messenger as saying, ‘‘The gift to a believer is death.”( i.e. death is the means by which he gains an introduction to the delights of paradise.)