He lost, but he also won. He was a dead man walking from the cancer, so dying wasn’t losing. In fact, he exited life on his own terms, without the indignity of trial and incarceration. He salvaged enough money to provide for his family and came up with a method for getting the money to them in a manner they would accept, exactly as khe intended from the word go. He avenged himself on the Meth Nazis while simultaneously protecting his family from them, and he did it in characteristic Walter White style - blindsiding them with science. He even saved his long-time partner in crime, Jesse, with one last act of humanity, even if he didn’t particularly intend anything of the sort going into the showdown. He got to see his son and daughter one last time, and give Skylar closure. In those senses, yeah, he won.
He lost in that he effectively accomplished all that at a terrible cost. He died alone, unloved and misunderstood by his family, having caused, however unintentionally, the death of a family member, a line he did not want to cross. His name would be poison, and a terrible scar to those he professed to love. That was his punishment.
Overall, yes, he lost. Tactically, he salvaged what he could from a bad situation. Inasmuch as him dying was a given, things ended about as happily as they could.
For instance, he does NOT get to leave his family in a good position, or even anything close to that. Look where they live now! He left his wife with a card to play but what of it? She plays the card and gets out of trouble but now everyone knows she was in on it, hence having a card to play. She might even not be able to get completely out of trouble with it, who knows? The kids will either hate him(oldest) or not know him at all(youngest). He even has to face his selfishness head on. The kids’ money? There are any number of ways they might try to weasel out of that, it’s nowhere near a done deal that they ever deliver. He dies knowing all this was his fault.
Skylar was ultimately complicit. Anything she salvages is better than being in jail. She suggested the murder of Jesse, so not a whole lot of sympathy for Mrs. Scarface. She suffers in purgatory for a year, and then is bailed out by the “compassionate” (scared shitless) Schwartz’s. They’ll follow through - their own guilty consciences and gutlessness will ensure that. The advantages of a bad reputation
So he killed some people. It was one of those ultimately empty gestures that people do to convince themselves there was a purpose or reason. He cannot undo whatever they did to earn their deaths, he won’t be around to see what he accomplished, if anything.
But he had a good time doing it. Job satisfaction. ;-)