The death of a star begins when the hydrogen fuel in its core runs out. The center of the star collapses under the pull of gravity, becoming highly compressed and white-hot. The temperature of the star rises dramatically, so much so that the helium, a by-product of fusion, begins to burn both inside and just outside the core, turning it into carbon. The star swells, and its outer layers expand. The star becomes monstrously large, growing into a "red giant." This phase lasts about 100 million years.
When the helium in the core of the star is exhausted, the star becomes a "red super giant." During this phase, lasting a several tens-of-thousands of years, the outer layers of the star blow apart and are cast off into space in a stellar wind. This loss of mass reduces the star to a hot core of carbon embedded in a nebula of gasses.
Eventually, comparatively little gas surrounds the core and radiation ionizes the gas, heating it rapidly and shooting it out at high speed, where it collides with cooler gas. This causes the gases to collect into a dense cloud called a "planetary nebula." This phase lasts about 10,000 years.
When the carbon eventually cools, the star becomes a "white dwarf." It drifts through space for millennia, cooling, until it becomes a frozen chunk of carbon, called a "black dwarf."
Massive stars, or "super giants," are roughly 10 times more massive than the Sun, and they not only burn brighter, they die more spectacularly. When the helium in a massive star burns out, the core contracts under so much pressure that carbon burns into oxygen, then into neon, then into silicon and finally into iron, the most stable form of nuclear matter. Iron does not produce the intense heat to generate enough energy to balance the pull of gravity and so the core collapses. When the core reaches nuclear density, it resists collapsing any further. This means that matter collapsing into the core bounces off, releasing energetic neutrinos. This results in a "supernova" explosion that spews elements into space, creating new galaxies. If its mass is between 1.4 and 9 solar masses, it can become a neutron star, comprised solely of neutrons; larger stars can collapse into a black hole.