only if you have no available heirs will there be an election.

this is the strong part of the HRE as other factions would die out in this situation and it would be game over.

however, if king dies with no heirs, a good stat general will be king and it will all be fine.

I've never actually needed that crutch but it's there.

however, the election means the nobles are more power hungry and there's no faction more prone to civil wars which are disastrous.