Well we believe that salvation comes through grace, which is a free gift. So the important criterion is grace, not works (what one does in one’s life). Now if one is in a state of grace one will typically do good works not in an attempt to ‘merit’ heaven (nobody can ‘earn’ heaven or conversely ‘earn’ hell) but as a consequence of being in grace.
Here’s the thing. Grace is a gift which can be accepted and rejected. . .over and over again. It is not a guarantee, a ‘once saved’ sort of thing. I can be in a state of grace and do good works as a consequence, but I’m not ‘earning heaven’. I am a ‘worthless servant’ because at the time of being in grace and doing good works, I’m just doing what I am supposed to do. And of course when I reject grace by doing evil, which is rejecting God, I have rejected salvation.
At the point of death if we are in a state of grace and with no attachment to sin we will be graciously (by God’s grace) allowed to enter heaven; if we are in a state of grace but still have a temporal attachment to sin we will be purified (Purgatory) and then enter heaven. If we are not in a state of grace we will have chosen hell. No matter what ‘good’ or ‘bad’ deeds we did in life, it does not matter if we are not in a state of grace at death.
That is what makes God so wonderful. His free gift allows a person to enter glory even if at times in the person’s life he did ‘wrong’. The glory is that despite doing the wrongs he did a final rejection of those wrongs and chose to submit his will to God’s.
And the sorrow of hell is that a person who may have done great good on earth, if he dies not in the state of grace, will have chosen to reject all the good he did and reject God’s will.
The main point is that God gives each and every person sufficient grace in his or her life to ‘choose Him”. So it’s never a ‘gotcha’ where God allows John to be a ‘good man’ for 70 years, make ‘one itty bitty mortal sin’ right before death, and then say, “Sorry, despite all your good deeds that one bad ‘cancels’ it —as if John would have gotten heaven BY HIS DEEDS. It doesn’t work that way.