A star with a mass much larger than the Sun starts in the same way, as a nebula that gravity pulls together into a main sequence star. But a larger mass means a hotter core and a much faster rate of fusion, so a massive star uses up its fuel more quickly and has a shorter life than the Sun.
When the hydrogen runs low, the star swells into a red supergiant, far bigger than a red giant. Fusion in the core now makes heavier and heavier elements, up to iron. After that the core can no longer release energy by fusion.
With no outward push to balance gravity, the core collapses and the star explodes as a supernova. The explosion throws the outer layers into space and creates elements heavier than iron. The dust and gas can later form new nebulae and new stars. The core left behind becomes a very dense neutron star or, if the star was massive enough, a black hole, where gravity is so strong that not even light can escape.