Technically, the sun will roast us long before [it dies]. We are going uninhabitable in a few hundred million years....If that fails, I am counting on elephants.
Interesting to find someone who is aware that current astrophysical models of stellar evolution do in fact predict that a star gets steadily brighter long before it leaves the main sequence. Of course that leaves the reasonable amount of doubt regarding how well our models portray whatever is actually taking place in the sky. Despite the heavy mathematization of physics and Stephen Hawking's assurances of the arrival of "precision cosmology," I see little reason to think we've heard the last word on this subject.
But "a few hundred million years" is quite a while. We have an extremely foreshortened view of natural history because the recent past is seen at higher temporal resolution than the remote past is. This motivates us to attach way too much importance to the human species and its civilizations in the overall scheme of things. It has also led us to assume that human beings, and life as we understand it today, are the final stage in evolution: Otherwise we wouldn't ask about how we will respond to the impending asteroid impact or the sun's death, while simultaneously overrating the lethality of pandemics.
Pandemics are hardly fun. But they don't destroy a widespread species too easily. Even if a lightning airborne disease killed 99% of today's population; some 70 million survivors would be left behind, more people than our planet hosted during the reign of Egypt's Amenemhat I. And these survivors would likely have natural resistance to the pathogen. Real pandemics such as the Black Death and Spanish Flu killed only a small fraction of the world population, never coming close to threatening an extinction.
Meanwhile, huge asteroid impacts of the sort that ended the dinosaurs occur so infrequently we will likely have disappeared or evolved into something unrecognizable by the time the next one comes. Of course there's always the risk. But even if it happened right now, would humanity die out? Many types of advanced life, including crocodiles, survived the asteroid that killed the dinosaurs. We are considerably more adaptable than any reptile. I would bet not only on species survival, but that we might rebuild civilization after an impact unless it's big enough to extinguish all multicellular life.
Extinction itself can be somewhat illusory. After all, some dinosaur lineages still have living descendants: We call them birds.