Just like anything else in the Universe, stars cannot live forever either. That’s because they run on fuel. What happens to them?
Stars are mostly balls of hydrogen gas that came together from a nebula of gas and dust. Fusion is the process where they generate their energy. This is where atoms of hydrogen combine together to form helium atoms. And in the process, the star generates a tremendous amount of energy in the form of radiation. Stars live based on their mass.
What exactly happens to the star depends very sensitively on what the mass of the star is.
Our Sun will be able to burn helium into Carbon and Oxygen. Stars significantly more massive will be able to burn Carbon and Oxygen into Neon, Silicon, and even more massive stars will eventually burn those into Iron. Most stars that fall into this category, when they run out of fuel that they’re able to burn, will expand into a giant star, and then contract into a white dwarf.
White dwarfs don’t burn anything, and are only “white” because they emit light due to the energy released from contracting gravitationally. When they’re done shrinking, they stop emitting light, and become known as black dwarfs. When they start to contract, the pressure on the iron core becomes so intense that it starts to fuse the protons and electrons found in the iron atoms into neutrons! This causes a tremendous release of energy, known as a supernova explosion:
Massive, average and small Stars.
The most massive stars quickly exhaust their fuel supply and explode in core-collapse supernovae, some of the most energetic explosions in the universe.
Average stars with up to 1.44 solar masses, such as the Sun, face only a slightly less exotic fate. As they run out of hydrogen to fuse in their cores, they swell into red giant stars before shedding their outer layers. The remnant left behind in these planetary nebulae is a white dwarf star. Like neutron stars, white dwarfs no longer fuse hydrogen into helium, instead depending on degeneracy pressure for support — this time, the electrons are degenerate, packed together and forced into higher energy states, rather than the neutrons.
The smallest stars in the universe live the longest lives, in fact, none have faced their end yet. Red dwarfs, stars with less than 0.4 solar masses, burn so slowly that they might live to 100 billion years old, much longer than the current age of the universe.