Peace Sstikstof.
Let us look at the subject and context of 4:17:
4:16
The couple who commit adultery shall be punished.* If they repent and reform, you shall leave them alone. God is Redeemer, Most Merciful.
وَالَّذانِ يَأتِيٰنِها مِنكُم فَـٔاذوهُما فَإِن تابا وَأَصلَحا فَأَعرِضوا عَنهُما إِنَّ اللَّهَ كانَ تَوّابًا رَحيمًا
4:17
Repentance is acceptable by God from those who fall in sin out of ignorance, then repent immediately thereafter. God redeems them. God is Omniscient, Most Wise.
إِنَّمَا التَّوبَةُ عَلَى اللَّهِ لِلَّذينَ يَعمَلونَ السّوءَ بِجَهٰلَةٍ ثُمَّ يَتوبونَ مِن قَريبٍ فَأُولٰئِكَ يَتوبُ اللَّهُ عَلَيهِم وَكانَ اللَّهُ عَليمًا حَكيمًا
4:18
Not acceptable is the repentance of those who commit sins until death comes to them, then say, "Now I repent." Nor is it acceptable from those who die as disbelievers. For these, we have prepared a painful retribution.
وَلَيسَتِ التَّوبَةُ لِلَّذينَ يَعمَلونَ السَّيِّـٔاتِ حَتّىٰ إِذا حَضَرَ أَحَدَهُمُ المَوتُ قالَ إِنّى تُبتُ الـٰٔنَ وَلَا الَّذينَ يَموتونَ وَهُم كُفّارٌ أُولٰئِكَ أَعتَدنا لَهُم عَذابًا أَليمًا
Qoran is talking here about a specific sin, adultery. Although repentance applies to all sins.
4;17 and 4:18 go on to explain repentance in general
So if one repents, knowing full well ,this is a sin, obviously they need to stop it immediately, once they realise /know it is wrong.
If one carries on,knowing full well they are committing a sin,then they either do not want to stop immediately or they might stop in the future...Or until it is time to die( No one knows how long in the future they are going to live!).then obviously they are not repenting?
Hope that helps.
GOD bless you.
Peace.