image credit: NASA, ESA, H. Bond (STScI), R. Ciardullo (Penn State), and the Hubble Heritage Team (AURA/STScI); image source; larger image
When the Sun reaches the end of its life, its outer layers will drift into space, an intricate cloud illuminated by its hot, dense core, as in this false-color image of a planetary nebula and white dwarf. For more details, see this page on the death of solar-mass stars.
How a star lives and dies depends upon its mass. For an overview of the lifetime of different types of stars, see The Life and Death of Stars. For very thorough explanations, see the Stellar Evolution pages from the Chandra website.
(This feature was updated on July 29, 2013.)
Death Star: A Bad Day In the Milky Way
Another possible fate for especially massive stars is to explode in a hypernova, causing a gamma-ray burst. To learn about the effect a gamma-ray burst would have on Earth, check out Death Star: A Bad Day In the Milky Way.