As we saw, the mass of a star determines its lifetime on the Main Sequence, but it also determines the final stage of the star. We must distinguish two categories to explain this final stage:
These numbers are approximate. There is no sharp boundary.
After a “low” mass star up to 8 times the mass of the Sun exhausts the supply of hydrogen in its core, there is no longer a source of pressure to support the core against gravity. The core of the star shrinks and heats up, leaving an outer layer of hydrogen around it that continues the fusion to Helium. This causes the outer layers of the star to expand rapidly. Due to this expansion the temperature in the outer layers rapidly decreases and the star becomes what is called a Red Giant star.
Red Giant stage of a medium sized star.
Helium continues to be produced around the already hot core and pressure keeps building up inside, until the Helium can start to fuse to Carbon in the so-called triple-alpha process. Although the core is now very hot, the rest of the star cools down and shrinks. This is the end of the Red Giant stage.
The triple-alpha process produces Carbon from Helium.
The helium fusion is unstable and the star pulsates, expelling a lot of material from the outer layers. leaving behind a hot core embedded in a nebula of expelled gas. Radiation from this hot core will ionise the nebula, producing a Planetary Nebula. The core is now rich in Carbon and Oxygen and becomes extremely dense and hot. But when the helium is depleted, the core slowly cools down and becomes a White Dwarf.
The Cat's Eye Nebula is an example of a planetary nebula formed by the final stage of a star with about the same mass as the Sun.
Source: Image Tours at http://hubblesite.org/gallery/tours/