He also achieved his end goal. He was able to take care of his family, didn't leave them in debt, left Walter Jr with a nice chunk of change.
You are right that not only does he get screwed but he doesn't even get credit for it. He does everything for his family and even his own son hates him in the end.
I guess that is part of the beauty in it that not only does he give of all but he gets no credit in return. Totally selfless and cool.