John realizes what a selfish bastard he is when he's sitting next to his dying son in the hospital, holding his hand and hoping and praying to God that Dean wouldn't die.
He supposes he never realized it before because of what a selfish bastard he is, but now that he knows his end is near, he looks back on his life and doesn't like what he sees. Everything he had done in the past twenty-three years had been for him: seeking revenge, hunting, studying the supernatural. He wanted revenge against that demon because he knew it would be the only thing that would bring him peace now that he knew about the things in the dark. Revenge consumed his thoughts and for a while, it even filled the gaping hole that Mary had left in his heart. He tried to convince himself that he was doing it for her, that he was dragging their sons around from state to state because of her, but now he knows better. He did it for him. It was the only way keep could keep on living.
He knows if Mary had been alive, she would have divorced him or killed him long ago for what he did to his sons. She had longed for a nice home to raise their kids, to make memories, to grow old together. She had loved their family and that house, but God damn it, she had burned in there, glued to the ceiling and bloodied. He couldn't stay there, not with that memory to haunt him for the rest of his days, so he took his sons in the impala and didn't look back. She would have hated him for that. He hates himself.
John has a lot of regrets. He regrets all the times he moved his sons from place to place without warning; he regrets never going to Sammy's soccer games or Dean's baseball games; he regrets teaching his sons to hold and shoot guns when they were old enough to understand what bullets did; he regrets not visiting Mary enough, even though the pain was too much and kept him away (as if that would make it less real); and he regrets not kissing her enough, not hugging her enough, not telling her that he loved her every single minute of every single day. God, if he could go back and change it all, he would. He knows that if he had been the one who burned that day, Mary would have mourned him but moved on with her life. She would have let him go. She would have raised their children to be firefighters and lawyers, not killers and outlaws. She would have let him go, which is more than he had done for her. He should have done it differently; after all, how many people had he seen move on with their lives after the Winchester boys had saved the day? But he is weak and selfish, and he can't let her go.
She is perfect in his memory, never angry or sad. He forgets what a terrible cook she was, how scary she looked in the morning without makeup. He forgets that she had a temper like a waiter who just got off a triple shift and made no tips. All he remembers is her perfect golden hair, her green eyes, her freckled cheeks. He remembers her laugh and her voice and her perfume. Even after twenty-three years, his heart aches a little every time he smells lavender perfume. He can't let her go, so he hunts things, hoping to kill her killer. He knows it's selfish of him, but he can't seem to stop.
So he hunts. He hunts scary thing, silly things, and all the things that grace horror movies. He saves people and its great and everything, but it doesn't change the fact that he couldn't save her. He brings his boys on hunts, and he knows that the hunting world is no place to bring kids, but he can't stop hunting while knowing what's out there and he can't leave them while knowing what's out there. He can't lose them, too, because that would be too damn painful. John learned long ago that he can't win, but he never expected the taste of defeat to be so bitter. So he brings his kids on the road with him and teaches them what he can, gives them what he can while they give him everything. Which is why he's in the hospital, holding Dean's hand and wondering how his selfishness became too much for the three of them to bear.
He knows Dean's dying. He's known it ever since that demon – the Yellow Eyed Demon! – used its freaky mind shit and opened his son's chest. He knows it's all his fault; that if he hadn't been so adamant about killing that thing, that Dean would be breathing on his own right now, cracking jokes and diffusing the tension between John and Sam. And deep down, John knows that Dean would do it all over again if his father and brother would live. He's that selfless.
He's everything John's not.
Dean is funny and fluid and just so goddamn good that he makes John feel like a piece of shit in comparison. He's selfless to a fault, and he's got so much of Mary that sometimes it's hard for John to look at him. And he knows that's wrong, too, but he can't help it. He can't help wishing that she was there just to take the pain away. And Dean is so much like Mary that it hurts. So he knows what he has to do.
He can't lose Mary twice. That would just be too painful. He can't lose Dean. He knows what he has to do and although it hurts him to have to give up on his revenge, he needs to do it. It isn't even an option anymore. So he stares long and hard at his son for a long moment before standing up and feeling to make sure the Colt is tucked safely in his jeans.
The Colt: his last chance at killing the Yellow Eyed Demon. He searched so hard for this stupid gun and now he has to give it up, give up the dream that has consumed him for the last half of his life. And that hurts a lot, but his willing to make the sacrifice. It's Dean, after all.
And so when he leaves to bargain with that damn demon that had stolen so much from him, he knows he's not being selfless; he's doing it so he won't lose his son, because that would just drive him to the edge.
His final act is selfish, but John Winchester wouldn't have done it any other way.