It's a combination of age and mass mostly. Smaller mass stars follow different life-cycles than higher mass stars. For example, a star of 0.2 solar masses will live a very, very long time but will never be able to do anything besides turn hydrogen into helium in its core. As it ages and runs out of fuel, turns into a white dwarf, and then starts to cool off until, many billions of years later, it finally cools off to ambient temperature in space (less than a few kelvin). However, a star of 10 solar masses ages extremely rapidly, staying on the main sequence for only a few million years or so before igniting helium fusion in its core. It then undergoes a series of events that ping-pong it back and forth between expansion and contraction phases, moves up from burning helium to burning heavier and heavier elements, until finally it explodes as a type-II supernova.
The only difference between these two stars is their initial mass, yet this single difference causes a drastic change in their overall life-cycle. While different compositions can also create differences in their life-cycles, these are less drastic by comparison.