The thing about the soul is that it really can’t lie to itself.
Say you get in an argument with your best friend. You’re hopping mad and unreasonable. But even in the midst of your anger and unreasonableness, you know, deep down inside, whether your anger is just, or if you’re overreacting, or if you’re blaming your friend for something that’s someone else’s fault, or if you’re in the wrong yourself, or something else. It might take hours, or days, or months, or years for the rest of you to be able to catch up to what you know in your heart, and perform the required actions-- whether it’s calming down, apologizing, making amends, or being open to someone else making amends.
Same thing for mortal sin. Let’s say you were part of a gang and killed someone. Twenty years down the future, you would have eventually extricated yourself from gang life, realized how much of your life you had wasted, realized how your actions had ruined other people’s lives, and repented. Maybe your sense of right and wrong were so warped that even when you were in the midst of gang life, you thought it was justified or reasonable or acceptable.
But the moment you die, you see things clearly. You see the ravages of your sins on your soul. There’s no pretending in front of God. And you can either be tremendously sorry and repent and depend on God’s mercy, or you can be hardhearted and not repent and reject the love of God. Remember that we’re all judged individually-- more is expected from certain people, so a gangster who’s known nothing but slums and poverty is going to be judged differently from a Benedictine monk or a Jesuit professor.
You come across this sort of thing in private revelations on Purgatory, for example. A young man died unexpectedly while saving people from an avalanche, and all the townspeople were all, “Wow, glad I’m not
him. Remember the rotten life he lived?” But he sacrificed his own life for love of others, and the merits from that helped redeem him in the end. Or a woman who lived her whole life selfishly ended up dying in a train accident-- but her last thought was along the lines of, “Thank you for taking me so early, God, so I can’t keep offending you.” That kind of contrition also helped redeem her.
Judgment is ultimately up to God. I’m not about to speculate on whether this person will end up in Heaven, but that person can’t escape hell-- I’ll leave that to other denominations.

But your soul can’t lie to itself, and it certainly can’t lie to God. In that sense, the timeline of your life has less of an impact, apart from your ability to make reparations for your sins while still alive. But that’s different from actually feeling repentance in the first place.