6.- We must not forget that God is omniscient and knows everything, even before it happens. It is quite possible that He, seeing from eternity the prayer of his children for themselves or for others (for example the prayer of a mother), may have poured out graces that moved them to conversion before they died. Only God knows if at the last moment someone had repented of what he had done (with eliminating love for God and neighbor).
If this happens and / or that person has confessed with his mouth that Jesus is Lord and believes in his heart that God has raised him from the dead, he will be saved (Rom 10: 9). And even the simple attrition is enough to be saved, although it has less merit and therefore more purgatory. There have been cases of atheists who, when they saw themselves close to death, prayed. Someone has said that “when a man takes a step towards God, God takes more steps towards man”.