As a red giant, the hydrogen gas in the outer shell continues to burn as the temperature in the core continues to rise. At 200,000,000 degrees Celsius, the helium atoms fuse to form carbon atoms in the core. The last of the hydrogen gas in the outer shell is blown away to form a ring around the core. This ring is called a planetary nebula. When the last of the helium atoms in the core are fused into carbon atoms, the medium size star begins to die.
Gravity causes the last of the star's matter to collapse inward and compact.
This is the white dwarf stage which is extremely dense. White dwarfs shine with a white hot light but once all of their energy is gone, they die. The star has now reached the black dwarf phase. Once massive stars reach the red giant phase, the core temperature continues to increase as carbon atoms are formed from the fusion of helium atoms. Gravity continues to pull together the carbon atoms in the core until the temperature reaches 600,000,000 degrees Celsius.