Eventually, the core of a red giant runs out of helium. It contracts again, to maintain its temperature (gravitational energy -> thermal energy).
Helium ignites in a shell around the inert carbon/oxygen core. Now the star has a helium-fusing shell and a hydrogen-fusing shell.
With its hotter core and rapid fusion, the star becomes more luminous, and its envelope expands once again. It goes back up the giant branch. (Strictly speaking, it goes up the ``asymptotic giant branch.'')
The very luminous, very extended star begins to lose its outer envelope, where the push of radiation becomes stronger than the pull of gravity.
What happens next depends critically on the star's mass. In brief, stars whose main sequence mass is less than 8 Msun become white dwarfs (this lecture). More massive stars go through further fusion cycles and explode as supernovae (lecture 14).
No two electrons may occupy the same quantum mechanical state.
Rough translation: No two electrons may be in the ``same place'' moving at the ``same speed'' within some accuracy
Implication: When gas is extremely dense (so that many electrons are crowded into roughly the ``same place''), some of the electrons must move very fast.
If gas is dense enough, the ``degenerate'' electrons can provide pressure even if the temperature of the gas is low.
This degenerate electron pressure (or degeneracy pressure) is quite different from the pressure of an ideal gas, which drops when the temperature drops.
When a red giant core runs out of helium, it contracts.
It can stop contracting if it gets so dense that it is supported entirely by degenerate electron pressure, since losing heat no longer reduces the pressure.
If the star's main sequence mass is less than 8 Msun the core never gets hot enough to ignite carbon fusion.
As the star's envelope expands, we see in to a hotter part of the star, and it moves to the left in the HR diagram.
The hot core lights up the outer envelope, turning it into a spectacular, glowing planetary nebula.
Eventually, the envelope of the star is lost completely.
We are left with the former red giant's hot, dense core, mainly carbon and oxygen, perhaps with some helium and hydrogen near the surface.
This white dwarf is supported by degenerate electron pressure, so it doesn't contract even though it radiates heat.
It radiates and cools, like a glowing charcoal (but much hotter).
The surface cools to a few thousand degrees over about 10 billion years.
White dwarfs are extremely dense. A white dwarf with the mass of the sun would have about the same radius as the earth! (The sun's radius is about 100 times the earth's radius.)
A strange feature of degenerate electron pressure is that a more massive white dwarf is smaller than a less massive white dwarf. Its electrons must therefore move faster to provide the necessary pressure support.
Subramanyan Chandrasekhar (1931) realized that important changes to degeneracy pressure occur if electrons start moving close to the speed of light.
He concluded that white dwarfs with mass M > 1.4 Msun cannot exist.
The most massive white dwarf known is about 1 Msun, and most are about 0.7 Msun, in agreement with Chandrasekhar's theoretical deduction.
A very massive star, which would produce a carbon core more massive than 1.4 Msun, must have a different fate.
An extremely dense gas can be supported against gravity by degenerate electron pressure, which does not depend on temperature.
After exhausting its core hydrogen on the main sequence, a star with M < 8 Msun evolves through the following stages:
White dwarfs are the degenerate, carbon/oxygen cores of former red giants. They have no ongoing nuclear fusion.
A star with M < 8 Msun (on the main sequence) ends up as a white dwarf, cooling slowly, supported against gravity by degenerate electron pressure. In the battle between pressure and gravity, pressure scores a partial victory.
A white dwarf cannot be more massive than 1.4Msun, the Chandrasekhar mass limit.