A star, like our sun, burns hydrogen into helium. It later burns even heavier elements, and the star’s end comes, expelling its outer layers and has its inner core either contract or collapse down depending on what type of star it is. When stars extinguish, they collapse quickly under their own weight. Some stars that are large enough end their lives by exploding in a supernova.
Throughout their lives, stars are fighting against the crushing force of their own gravity. Inside, nuclear reactions fuse together smaller elements, like hydrogen, to create bigger ones and release energy. Stars must burn through fuel and release energy to prevent them from collapsing upon themselves, but this cannot go on forever.
Soon, the star will run out of its essential fuel entirely, resulting in an explosion. A star’s compression, which is many times larger than our Sun, can be so much that a rebounding shockwave is created. This can cause a final expansion that releases the layers of a star in a supernova.