It is caused by the contraction of stellar matter under the action of gravity.
In the later stage of evolution, the outer layer of a massive star expands outward and becomes a red giant or a red Supergiant star, while the inner core shrinks under the action of gravity due to nuclear fusion reaction. The more inward the stellar matter, the greater the atomic weight; The farther outward, the smaller the atomic weight.
When nuclear fusion occurs in stellar matter, the lighter the element (the smaller the atomic weight), the easier it will happen; The heavier the element (the greater the atomic weight), the less likely the nucleus is to fuse. When the central matter of a massive star is fused to produce iron, it can no longer be fused, and the nuclear fusion reaction in the star core will stop. From the core to the outside, various elements are distributed in layers, and various ongoing nuclear fusion reactions occur at the interfaces of each layer. The whole star is like a giant onion. As shown below.
Stars are stabilized by the balance of outward radiation pressure and inward attraction generated by internal nuclear fusion reaction. Once the nuclear fusion reaction in the center stops, the outward radiation pressure used to balance gravity will not exist, and gravity will prevail, so the inner star material will shrink inward, which will increase the center density and compress the iron into one by one. This state is called "electronic degeneration". Because the atoms are compressed to be arranged next to each other, the core of a star made of iron can no longer be compressed.
With the progress of various nuclear fusion reactions in the outer layer, there are fewer and fewer nuclear "raw materials", the stars expand more and more, and the temperature and density drop, which will eventually stop all nuclear fusion reactions. As a result, the outward radiation pressure disappears completely, and the role of gravity is unstoppable, and all substances outside the star core begin to collapse toward the center. This phenomenon is called "the core disaster". Like a falling body, this kind of collapse is not fast at first, but it will get faster and faster. When the outer material approaches the inner core of the star, its speed has increased to near the speed of light and will eventually hit the inner core of the star. But the inner core of a star is composed of iron and degenerate electrons, which is incompressible. These substances are like hitting an extremely hard wall. As a result, these impact materials will rush out of the star from the opposite direction at almost the same speed under the action of reaction force, and implosion will destroy the star. This is a supernova explosion.
Supernova explosion is the end of large-scale life. In the supernova explosion, the star becomes a nebula, leaving a neutron star or black hole with extremely high density and small size in the middle.