Yeah, ultimately it ends up being decided who the military is backing. Look at Spain, initially overtaken by a military coup. Then after Franco's death, as the transition to full blown democracy was already happening, sometime in the 80s (23-F), right as the successor to Suárez was about to take place, the military attempted another coup, but this time the military was on the people's democracy side, and basically saved democracy that day.
Really a hit or miss concept, military coups.