That works for conventional villains, like Villain A took over a town. Not Tiamat manifesting into the world, or Demogorgan pulling the world into the Abyss and making it his 3rd layer.
Sure it does. The new party, at low levels, fights the desperate fight against cultists and minor demons, struggles to help survivors find relative safety, and begins plotting out who or what might make allies and what they might want in exchange for that alliance. At mid levels, the party makes strategic forays against Demogorgon's lackeys to undermine the big D's authority, to promote insurrection, or to create distractions. Eventually, at high levels, they forge an alliance with devils/Orcus/celestials and works to create a big battle during which they can try to reverse the worst of the effects D has created.
Alternatively, maybe they are from another world entirely and are a group trying to rescue the lost world.
Alternatively again, maybe they try to use time travel shenanigans to try to prevent D from having won in the first place. Etc, etc.
Just because you can't think of a way for the pcs to overcome the challenge doesn't mean that they can't. Personally, I think that all adventures would be improved if they have, at the least, a sidebar about "what if the good guys lose?" (as well as "what if the pcs join the bad guys?"- I know Savage Tide addressed this at several points!).
Sure it may take years to wipe all life off the planet, but these events will be a desperate fight into futility. This is the problem with high level campaigns. If the heroes die, there is no one strong enough to correct their failure, and the consequences are irreversible.
That's one take on it. But there's no reason that has to be the only take on it.
Take the new Baldur's Gate campaign for example. What hangs in the balance for the players, is the fate of 1 city. They can continue on and determine the fate of Avernus also, but for that to happen, they will have to adventure past where the game actually wants you to end.
The game doesn't actually want anything. It may not spell out what happens after the end of the written adventure, but there is typically no reason whatsoever that it can't continue, even after a win by the bad guys.