The sun will engulf the planet eventually, but not for billions of years. Most likely before that happens we will be gone. Global warming is shaping up to be a massive problem that may well wipe out most of humanity in the next 50-100 years, combined with our over consumption of the planet's resources, and peak oil, something will give eventually. Did you know we are in the 6th great extinction event the planet has ever seen? We are causing the extinction of thousands of species a year. In the last 100 years (a few generations) global human population has gone from 2 billion to 6 billion, we are really out of control as a species. Also many doctors are worried about a lethal disease that will traverse the globe easily due to airplanes etc.. and wipe out 99.99% of the population.
Some optimists argue that we will travel to the stars, meaning that even when the sun dies humanity will survive. I think this would be wonderful but I am not so sure if this will happen.
Ultimately no one is really sure what will happen, but most of the greatest thinkers of our time see some kind of global calamity in the near future that will wipe out most of us. Depressing but true. Perhaps we could then bounce back from this and learn from our mistakes.. but again I am not so optimistic.