Indeed, it would be an interesting question... what drives authoritarian regimes to give up power voluntarily? The Pincohet and Franco regimes, while horrible, gave way to free elections without the need for much political struggle. The Communist regimes on the other hand gave way only when their hands were forced by an unwilling military. Is that accurate to say? It seems so.
The Franco regime never gave up power, Franco died. Franco installed Juan Carlos I of the Carlists as King and raised him to be his successor and to carry on leading the country as Franco did. Once Franco died, Juan Carlos had no one to answer to and told people to prepare for elections in a year, pissing off a number of Spanish conservatives. The military attempted a coup to gain
back their power, but Juan Carlos held his ground and the Spanish public accepted him, even the left-wing politicians that were anti-monarchist.