I want to know what was the primary reason for Walt eliminating Jack's gang at the end of Breaking Bad. The primary reason that he returned to ABQ because he wanted to give his money to Gretchen and her husband, but he came prepared in the town with his machine gun. At this point he did not know that Jesse was still alive or that Todd went to his home to talk to Skylar. What was the main reason? Was he furious over the fact that they took his money from him or did he wanted to avenge Hank's death or was this all an attempt at his redemption?
In Felina, though not referenced in the WikiPedia article - though explained here, Walter meets up with Badger and Skinny Pete after insisting that Elliot and Gretchen deliver the money to Walt Jr (and discussing terms).
Walter had heard rumors that the Blue Meth was still being manufactured. He asks Skinny Pete and Badger; Pete and Badger state "We thought you (Walter/Heisengerg) were making it."
Walter interprets this to mean that Jesse is still manufacturing. He doesn't know the specifics at the time (the specifics being that Jesse is being held hostage to manufacture the meth), but does not appear to be happy that the Blue Meth is still being manufactured - and also that the public is under the impression that Heisenberg is manufacturing said Meth.
Walter then intercepts Lyida and Todd at the cafe, which is how Walter confirms that Jack's gang is responsible for the manufacture of the Blue Meth.
It isn't until the confrontation, later - that Walter is able to confirm that Jesse is an unwilling captive. Walter uses the claim that Jack never followed through on the agreement to kill Jesse to in fact confirm the condition of Jesse (Jack has to have Todd bring Jesse to the house to confirm Jesse's status to Walter).
At this point the Machine Gun is triggered - where Jack's gang is wiped out.
You'll notice the final scenes of the series are Walter enjoying his creation, the design, and the specifics.
Aside that Walter had agreements for a similar manufacture in Arizona (this is where Jack stole the equipment from) - the bottom line is that Walter did not want his legacy of such a pure meth to exist in the hands of someone else - as he knew he was going to die.
The scene in the car after Elliot and Gretchen's place seems to confirm that Walter would not stand for the ultra-pure meth to be manufactured and sold in Albuquerque without him (Walter).
The final episodes of Breaking Bad are all about Walt going on a journey of redemption. The collapse of his empire and the loss of his family along with his solitary exile have made Walt cognizant of all the terrible things his actions resulted in. The fact that this journey would also result in the destruction of his enemies who have laid him low would definitely have appealed to his ego, but redemption was his main goal as evidenced by him finally confessing to Skyler about his true motivation and revealing the final resting place of Hank.
By paying Jack's gang he not only intends to destroy them, take vengeance for the death of Hank and all the other people they killed, but he would also rescue Jesse. Walt had wronged Jesse in so many ways that rescuing him (or at least attempting to) had to be part of his path to redemption.
Aaron Couch (the Hollywood reporter): Gus was a genius, and it took Walt many, many moves to kill him. Jack and his gang are not particularly smart, but they are brutal -- and Walt uses brute force to kill them. Was that an intentional parallel?
Peter Gould: We knew we'd had the greatest chess master opponent ever, and that Gus was more than Walt's match. But let's not forget that it was Walt's idea to get into business with these guys. Walt is the one who unleashed all of this hell. It's really a question of how he's going to put this hell back in this box.
Walt sought revenge, first by handing over Jesse to the neo-Nazis (who gave him two scoops of torture and ice cream), and then by returning from cold and lonely New Hampshire to wipe out Jesse along with Uncle Jack (Michael Bowen) and his crew.
In that same article, Bryan Cranston explains:
“[When] he hears that the blue meth is still out there, that Jesse is still cooking, it’s like, ‘That bastard! He convinced them to be a partner with him, he’s still cooking! I’ll kill everybody!’” says Cranston.
“Oddly enough, the revenge stuff at the end is — this is an odd way to put it because it’s so violent — but that’s sort of the cherry-on-top stuff, that’s the stuff that the audience needs to see for their own emotional contentment. At the end of the hour, the audience needs to see Walt get revenge against the guys who killed Hank. That’s sort of a necessity, and that stuff was a little more clear-cut.”
In another article (which explores endings they considered but didn't use), Gilligan looks at it in a broader context:
"Felina," the title for the final episode, comes from the Marty Robbins song "El Paso" that plays in the Volvo as Walter tries to steal the car. Gilligan explains that the man in the song "El Paso" kills another man because of his love for "wicked Faleena." The man leaves town, but eventually returns on his horse because his love for Faleena is stronger than his fear of death, and he gets killed upon his return.
Gilligan felt that the story in the song captured the essence of Walter's decision to return to Albuquerque. Writers assistant Gordon Smith and script coordinator Jenn Carroll pointed out to Gilligan that if they changed the spelling to "Felina," the title becomes an anagram of "finale."