The church says that people usually go to Hell if they die with confessed mortal sins, but it also states that God sometimes makes exceptions to this rule. A specific example that comes to mind is suicide, and the Catechism’s stance on those who commit it:
"Suicide contradicts the natural inclination of the human being to preserve and perpetuate his life. It is gravely contrary to the just love of self. It likewise offends love of neighbor because it unjustly breaks the ties of solidarity with family, nation, and other human societies to which we continue to have obligations. Suicide is contrary to love for the living God …
We should not despair of the eternal salvation of persons who have taken their own lives. By ways known to him alone, God can provide the opportunity for salutary repentance. The Church prays for persons who have taken their own lives."
In other words the Catechism is saying ‘Suicide is still a Mortal Sin BUT people who commit it might still go to Heaven despite being unable to preform the sacrament of reconciliation.’
I think that if someone dies with unconfessed mortal sins, but was sincerely repentant and planned on going to confession, then a reasonable and loving God would make an exception.
But still go to Confession when you can. At least twice a month as a rule of thumb, and pray in-between so that if you die before you can reach Confession God will understand that you tried your best.
You are confusing
grave matter with
mortal sin.
Grave matter means that an action in itself is profoundly evil. It is an essential
part of mortal sin.
Mortal sin means that one has committed an act that constitutes grave matter,
AND a person knows that it is grave matter,
AND the person acts in complete freedom in choosing to commit an act of grave matter.
In your example of mercy being shown to the person who has committed suicide, it is not that God shows mercy to one who has committed an unrepentant mortal sin. Of course He could – He is GOD!

But a soul in that state – in unrepentant mortal sin – would not accept God’s mercy, and has already made his choice against God through his lack of repentance.
God can indeed show mercy, however, to one who has committed suicide, because often (and sadly) suicide is not a mortal sin for that person. Yes, it is absolutely grave matter. And the person may know that it is grave matter. But suicide often arises out of mental illness, and that means the person is
not acting in full freedom – not even close.
I had a very dear friend who committed suicide some 25+ years ago. She was struggling with mental illness and even in her death was trying to reach out to God for help.
Grave matter? Yes.
Mortal sin? Only God knows the suffering of her soul, poor dear. We can absolutely trust in His mercy for her and others like her!