At the end of Act 4, Proctor is ashamed of himself for "confessing" to witchcraft because he is lying. Even though he lies to save his own life, it still feels wrong to him. Earlier, when speaking with Elizabeth, we saw him attempting to justify to himself why such an action is right. He says,
God in Heaven, what is John Proctor, what is John Proctor? [....] I think it it honest, I think so; I am no saint. [...] Let Rebecca go like a saint; for me it is fraud!
Because of his prior sin of adultery, Proctor believes himself to be beyond redemption, already lacking in integrity. If he's already damned, then what's the harm of telling a lie now? He cannot be more damned, and so he might as well live. He says that others, like Rebecca Nurse, really are untainted by sin and so it would actually be a lie for him to go to the gallows looking like he, too, is sinless. When Elizabeth will not say that she would lie in his place, he says, "It is evil. Good, then -- it is evil, and I do it!" He no longer feels that he has integrity, as Rebecca and Elizabeth do, and so he would be misrepresenting himself if he acted as though he did.
When Danforth then requires him to sign his "confession" so that it can be hung on the church door for all to see, John signs it but immediately snatches it up, refusing to hand it over. He cries that he will not hand over the signed document
Because it is my name! Because I cannot have another in my life! Because I lie and sign myself to lies! Because I am not worth the dust on the feet of them that hang! How may I live without my name? I have given you my soul; leave me my name!
He feels that, in confessing a lie, he has not only cemented his own lack of integrity but also that he has confirmed his own moral worthlessness. His lie, though it will save his life, will appear to confirm the guilt of the others who will not confess, and this brings him even lower in his own eyes. Without integrity, all he will have left in his life is his reputation, and his reputation will be blackened by the appearance of his name on this dishonest confession. According to Miller's stage direction, Proctor "knows it is insane." It doesn't really make sense that his name, his reputation, what others think of him, should seem to be worth more to him than his own integrity, what he thinks of himself. And so he tears his confession up, crying,
You have made your magic now, for now I do think I see some shred of goodness in John Proctor. Not enough to weave a banner with, but white enough to keep it from such dogs.
In this moment, he seems to realize that his prior sin of adultery does not mean that he cannot redeem himself in this moment. He may have made the wrong decision then, but he can make the right decision now. In the end, his decision to not lie in order to save his life actually convinces him that he does still have some integrity left, and so he once more becomes sensible of his own "goodness." Integrity is so important to his sense of self that he chooses to retain it and die rather than sacrifice it and live.
His wife, too, realizes the power such a realization has had on Proctor, and when Hale begs her to reason with him, she says, "He have his goodness now. God forbid I take it from him!" In the end, integrity is more vital than reputation, and in preserving his integrity, Proctor keeps his name -- his reputation -- in tact as well.