In Coke's case, the company realized quickly how badly they'd blundered and brought back old Coke as Classic Coke. And, this is the part everyone outside of the soft-drink business forgets, Coca-Cola actually immediately came back stronger than ever. Decades later, the Cola wars are history and Coca-Cola is the winner.
How did Coke do it? They gave people what they wanted: The original "taste." As Coca-Cola chairman and CEO Roberto Goizueta said in 1995, "The most significant result of 'New Coke' by far was that it sent an incredibly powerful signal... a signal that we really were ready to do whatever was necessary to build value for the owners of our business."
I've suggested Microsoft do the equivalent by bringing back the Aero interface and dumping the Metro interface. Does Ballmer have the guts to admit he made a mistake and give users what they clearly want? We don't know.