When sunlike stars run out of fuel, they explode in a series of pulses, throwing off much of their mass in the form of a giant shell of gas called a planetary nebula. What remains of the star is a superdense white dwarf star at the center. The star's planets, if any, are shattered by the blast. This could be the fate of Earth.

Full Story: Watery Asteroid Found Around Dying Star, Potential Habitable Planet Ingredient

Stars begin their life cycle as a nebula. For 50 million years, gas and dust collapses under its own gravity and heats up from friction.

Once the temperature and pressure is right for nuclear fusion, the star ignites. Hydrogen is fused into helium.

For about 10 billion years, the star shines. Eventually, all the hydrogen is fused into helium, so heavier elements begin to fuse. Pressure builds, and the star expands.

Star Quiz: Test Your Stellar Smarts

Ultimately, the star swells to a huge size, its radius twice the distance between the Earth to the sun. This stage is called the red giant phase.

As it dies, the star blows most of its matter out into space, forming an expanding shell of gas. What remains of the star is a white dwarf.

In its death throes, the sunlike star destroys its planets. In 2013, the shattered remains of a water-rich minor planet was found orbiting the white dwarf star GD 61, about 170 light-years from Earth.

Video: How the Sun Will Die (and What Happens to Earth)

The corpse of a sunlike star has half of the mass of the sun packed into a body the size of the Earth. White dwarf matter is composed of carbon atoms that have been crushed by gravity. White dwarfs of more than 1.4 times the sun's mass become even more compressed, to the point where all subatomic particles are crushed into neutrons. Still larger stars become black holes.

Follow us @Spacedotcom, Facebook and Google+.