From Trustful Surrender to Divine Providence: The Secret of Peace and Happiness by Fr. Jean Baptiste Saint-Jure and St. Claude de la Colombière (p. 62)
Acceptance of our death and the manner of it must be in full surrender to God’s Providence.
it is the teaching of great masters of the spiritual life that a person who, at the point of death, makes an act of perfect conformity to the will of God will be delivered not only from Hell but also from Purgatory, even if he has committed all the sins in the world.
“The reason,” says St. Alphonsus, “is that he who accepts death with perfect resignation acquires similar merit to that of a martyr who has voluntarily given his life for Christ, and even amid the greatest sufferings he will die happily and joyfully.”