red giants stop fusing after helium and the star shrinks under gravity
it ejects the outer layer of dust and gas leaving the core which cools to form a super giant
super giants undergo more fusion so they expand and contract several more times
they fuse up to iron
eventually they explode into a super nova ejecting all the heavier element into space where they form new stars and planets
exploding supernova throws outer layers of dust and gas into space and gravity causes the core to shrink leaving a very dense core called a neutron star
if the star is big enough it will become a black hole