The gate of repentance is always wide open as long as the individual is not in the throes of death. Therefore, it is unbecoming for a Muslim to wait and delay repentance until it is too late. Almighty Allah has given His servants a chance to return to Him, but once a person dies, it will be the time of reckoning, not repentance.

Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states: Almighty Allah says in the Qur’an, (Tell My servants, O Prophet, that indeed, I am the All-Forgiving, the Mercy-Giving and that My torment is, indeed, the most painful torment, prepared for the unrepentant.) (Al-Hijr 15: 49-50). (Say, O Prophet: God declares to humanity: O My servants! Those of you who have committed sins in great excess against their own souls, never despair of the mercy of God! For, indeed, God forgives sins, one and all. Indeed, it is He alone who the All-Forgiving, the Mercy-Giving. So turn in repentance to your Lord. And submit yourselves willingly – before there comes to you the torment of God’s Judgment. For, then, you shall not be helped.) (Az-Zumar 39: 53-54).
In these and numerous other verses, Almighty Allah calls His servants to repent. The time when repentance will be of no avail is when the person is in the throes of death. In this context, the Prophet (peace and blessings be upon him), is reported to have said, “Allah accepts the repentance of His servant as long as his soul has not reached the collar bone!” In other words, repentance on one’s death-bed is not acceptable.
The reasons for this are clear: Islam teaches us that we are being tested in this world. The best way to understand this is to compare it to an examination hall, where everyone has a chance to write the test and gain good marks or correct what has been written until the bell rings. At that time, everyone has to hand over their papers for the time is up. The same is true of our life in this world and as Almighty Allah reminds us it is a test. Almighty Allah says, “He it is who created death and life in order to test you, to reveal which of you is best in deeds.” (Al-Mulk 67: 2). Therefore, we have been given the opportunity to repent and make amends until we come face to face with death. This is why Almighty Allah and His Messenger (peace and blessings be upon him) remind us not to postpone repentance until the last minute. Almighty Allah says, (O you who believe… spend charitably from whatever We have provided you before death comes to anyone of you, such that one would say: My Lord! If You would but defer me from death to a near term, then I will give charity and become of the righteous. But never will God defer the death of a soul when its due term comes. And God is all-aware of all that you do.) (Al-Munafiqun 63: 10-11)