Stars usually maintain a state of equilibrium with zero net forces acting on them. The main force that acts on the stars is the gravitational force which tends to shrink the size of the star and forces it to collapse. The other opposing force to the gravitational force is the force that is generated by the thermonuclear reactions in the star which convert hydrogen to helium in a fusion reaction process. This process releases an immense amount of energy that exerts a force which opposes that of the gravitational force. At equilibrium state the net result of the effect of these two forces is the cancellation of their effect.
The main contributor to the way that the star will collapse depends on the mass of the star and its radius. The gravitational force is proportional to the mass and the radius of the star. When a star begins to age, the amount of hydrogen in it begins to be depleted and the opposing force to the gravitational force will be weakened. Thus, several processes can start to occur and which lead to the death of the star.
A star the size of our sun usually ages by being converted into a giant red. Its outer layer is thrown into a planetary cloud. Stars like the sun become eventually white dwarfs. The difference between a white dwarf and a normal star is the source of internal pressure that balances the gravitational force. This pressure is due to the effect of degenerate electrons that prevent the further collapse of the planet. This pressure is also a function of the density of the star and not of the temperature such as occurs in gases of atoms and molecules. This electrons pressure prevents the further collapse of the white dwarf.
If the mass of the star is big enough so that the gravitational force is large enough, it can collapse further and become a black hole. A black hole is a massive star that has very high density with very large gravitational field. Thus electromagnetic radiation cannot escape the gravitational field of the black hole nor any other object. Other thermonuclear reactions which occur in the dying star due to the elevated temperature within it are the fusion nuclear reactions that convert helium to carbon atoms in addition to the nuclear combustion of carbon to oxygen. Also, carbon is being converted in a nuclear reaction to magnesium.
Very high temperatures are required for these nuclear reactions in order to proceed. The formation of iron metal is the last nuclear process to occur in the star. The other process which occurs during the death of a star is called supernova. In this process the star begins to collapse and iron metal in it begins to be transformed into alpha particles. As a result of the collapse the temperature of the star increases drastically. Electrons begin to bind to protons and form neutrons. A shock wave occurs which causes the external layers of the star to be scattered in space. This leaves a neutron filled collapsed star which is very dense.
The neutrons are like the electrons by exerting a pressure that opposes the effect of the gravitational force. This prevents further collapse of the star. Supernova is the ultimate source of the heavy elements by nuclear reactions. This way elements such as nickel and uranium and lead and others are formed. The mass that explodes in supernova is proportional to the mass of the star.