Massive stars fuse heavier elements in their cores than lower mass stars. This leads to the creation of heavier elements up to iron. Iron robs critical energy from the core, causing it to collapse. The shock wave, together with a huge swarm of neutrinos, blast through the star’s outer layers, causing it to explode. The resulting supernova creates even more heavy elements, scattering them through space. Also, happily, we’re in no danger from a nearby supernova.