Here's a breakdown:
* Fuel Exhaustion: Stars generate energy through nuclear fusion, converting hydrogen into helium. When a star exhausts its hydrogen fuel, it begins to fuse heavier elements like helium, carbon, and oxygen.
* Gravitational Collapse: As the star runs out of fuel, the outward pressure from fusion weakens, and the star's own gravity starts to pull inwards. This causes the star to collapse.
* Outer Layer Ejection: The collapse triggers a violent explosion called a planetary nebula, ejecting the outer layers of the star into space.
* White Dwarf Formation: The remaining core, now incredibly dense and hot, is a white dwarf. It is primarily composed of carbon and oxygen. White dwarfs are incredibly small, about the size of Earth, but they contain the mass of a star.
White dwarfs are essentially the "ashes" of a star, slowly cooling and fading away over billions of years.