The answers I’ve gotten here have ranged everywhere from “God forgives you as soon as you are remorseful” to “God won’t forgive you until you go to confession.”
One can be forgiven of venial sins anytime via prayer etc etc…mortal sins are possible to be forgiven prior to confession via the grace of perfect contrition which includes amendment and the intention to confess as soon as possible.
Can God give them the grace they need even in the last moments of life? Yes it is possible.
But while we are to have confidence …hope…we are to avoid presumption too.
Jesus tells us the parables of the Good Shepherd and the lost coin and the Prod. Son…and he also tells us to repent…and the parable of the man who builds the tower thinking he has all his life to use his stored grain (his soul is demanded of him that night!)…as well as to “watch” for we do not know the last hour…or his coming.
**
The Catechism of the Catholic Church**
Contrition
1451 Among the penitent’s acts contrition occupies first place. Contrition is "sorrow of the soul and detestation for the sin committed, together with the resolution not to sin again."50
1452 When it arises from a love by which God is loved above all else, contrition is called “perfect” (contrition of charity). Such contrition remits venial sins; it also obtains forgiveness of mortal sins if it includes the firm resolution to have recourse to sacramental confession as soon as possible.51
1453 The contrition called “imperfect” (or “attrition”) is also a gift of God, a prompting of the Holy Spirit. It is born of the consideration of sin’s ugliness or the fear of eternal damnation and the other penalties threatening the sinner (contrition of fear). Such a stirring of conscience can initiate an interior process which, under the prompting of grace, will be brought to completion by sacramental absolution. By itself however, imperfect contrition cannot obtain the forgiveness of grave sins, but it disposes one to obtain forgiveness in the sacrament of Penance.52
Venial sins can be forgiven in many ways…contrition…prayer etc etc