إِنَّمَا التَّوْبَةُ عَلَى اللّهِ لِلَّذِينَ يَعْمَلُونَ السُّوَءَ بِجَهَالَةٍ ثُمَّ يَتُوبُونَ مِن قَرِيبٍ فَأُوْلَـئِكَ يَتُوبُ اللّهُ عَلَيْهِمْ وَكَانَ اللّهُ عَلِيماً حَكِيماً  وَلَيْسَتِ التَّوْبَةُ لِلَّذِينَ يَعْمَلُونَ السَّيِّئَاتِ حَتَّى إِذَا حَضَرَ أَحَدَهُمُ الْمَوْتُ قَالَ إِنِّي تُبْتُ الآنَ وَلاَ الَّذِينَ يَمُوتُونَ وَهُمْ كُفَّارٌ أُوْلَـئِكَ أَعْتَدْنَا لَهُمْ عَذَابًا أَلِيمًا (4: 17-18)

It is incumbent upon God to forgive those who commit a sin in frenzy and then immediately repent. It is they then who are forgiven by God. God is All-knowing and Wise. But the repentance of those is not acceptable who sin all their lives and, when death comes to them, say: “I repent now!” nor of those who die as disbelievers. It is for these for whom We have prepared a dreadful punishment. (4:17-18)