The end stages of stars vary based on their mass. For smaller stars, like our Sun, they expand into red giants and eventually shed their outer layers, forming a planetary nebula. The core that remains becomes a white dwarf, which will cool and fade over time.
In contrast, massive stars undergo more dramatic transformations. After exhausting their nuclear fuel, they can explode in a supernova, leaving behind a neutron star or even collapsing into a black hole. These processes contribute to the recycling of materials in the universe, enriching the interstellar medium with heavy elements.