The clock is ticking inexorably toward doomsday even if we don't kill ourselves by poisoning the environment or overheating the planet. You see, there's a little problem with the Sun.
The Sun is slowly getting warmer as it burns the hydrogen in its core. In about 5 billion years, the Sun will begin evolving into a bloated red giant. Its outer gas shell will swell up, engulfing the Earth by the time it reaches its peak size and brightness 7 billion years from now.
By far the most ingenious take on this I've encountered in science fiction is Robert Charles Wilson's "Spin."