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.
‘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.”
Jabir reported God’s messenger as saying, “Do not wish for death, for the terror of the place whence one looks down in severe. It is part of a man’s happiness that his life should be long and God who is great and glorious should supply him with repentance.”