There isn't any disaster that would do that in the near future. And by near future I mean next few hundred million years. Even a giant impact as big as the one that brought an end to the dinosaurs would leave many human survivors deep underground or in submarines - and if we had advance warning we could prepera shelters for much of our population (as well as - look into ways of diverting it) unlike the dinosaurs.
Instead - there would be at least some survivors on the Earth. They would rebuild the Earth.
Also - the Mars survivors in a small base wouldn't last long without support from Earth - and indeed - if it is a technological disaster - long drawn out slow losing of our capabilities for technology - then a Mars base would be amongst first to go, because so much more dependent on technology than anyone else.
And - the chance of any disaster doing this in near future is tiny.
There has been enough time since the dinosaurs for tiny animals looking like this:
Will probably be at least as long before we have a dinosaur ending type asteroid impact extinction type event on Earth again. And the dinosaurs didn't have our technology (as far as we know).
As for a disaster that threatens humans with technology - you are talking about a period long enough to evolve from Tarsiers ten, or twenty times over - getting on for a billion years in the future when the seas boil dry as most likely extinction causing event - but who knows what technological society if any we will have by then.
I think idea that we need to leave the Earth to avoid extinction has no basis at all when it comes to natural disasters, simply isn't anything at all likely that is worth going into space to avoid. All of the credible ones leave some survivors on the Earth if we still have our current levels of technology. And if we don't - then for sure we don't have space colonies.
If it is us that are the problem - then space colonization is as likely to add to issues that may make us extinct as help with them. It needs great care I think - to do it properly - make sure we don't have issues such as wars - and huge economic imbalances leading to mass poverty. And means widespread availability of rockets which are - basically - ICBMs with humans on board.
Space does have great potential for solving many of our technological problems. But - also many things that can go wrong as well.
Let's not rush into it too quickly! But look forward and see what can go wrong and what can go right, and try to get it right and avoid the very worst mistakes at least.
More on the asteroid impact:
Spaceguard have mapped 800 of the 1 km objects which represent probably 80% of all the ones to be found with possibility of intersecting Earth orbit.
NASA has been tasked with mapping 90% of all Near Earth Objects over 140 meters by the end of 2020 and there are several future planned giant telescopes that will help to achieve this.
By then the chance that there is an unknown 10 km asteroid that threatens Earth, say, before the end of this century, will be minute.
The one wildcard here is a giant comet from the outer solar system hitting Earth on its first pass through the solar system. That could happen - but they are much rarer than the ordinary asteroid type impacts - and we would have at least months of warning. For a comet as big as 10 kms across we'd surely have years of warning before it hit the Earth.
And a 10 km asteroid is not large enough to make humans extinct given that we'd know about it probably for decades in advance, something as large as that - by 2020 when Spaceguard finishes its next phase. So you could spend trillions of dollars and years of time preparing and if necessary - building refuges for a large survivor population on the Earth. You just need to be underground or under the sea for a few hours to survive the global firestorm, if there is one - and then you can build on the ground again - and grow crops with artificial light during the "nuclear winter" until the Earth returns to normal again.
Indeed we'd probably have so much advance warning that even a 10 km asteroid could be diverted away - there are ways of diverting even large asteroids if you can start long enough before the impact.
And chance is so tiny for these big ones - some time in the next few hundred thousand generations us, or more likely a future species that evolved from us, will surely need to do something about it. It does happen. But I think right now we are better putting our effort into predicting and doing something about the smaller 100 meter to 1 km sized asteroids. We will almost certainly be hit by one of those before we are hit by the larger ones.
And for none of these, even the 10 km asteroids - in none of these cases would a colony of survivors on Mars or the Moon or anywhere outside of Earth be any use for rebuilding Earth - well less useful than a similar group of survivors on the Earth as they have to get back to Earth first which they might not be able to do. Unless they have rockets already to get back to Earth - we might need to rescue them instead when we get a chance to rebuild our space industry on Earth, if we can do that quickly enough and if they are able to survive that long..