As @Clyde as already pointed, it's just a game mechanic that is unavoidable and pointed out here http://www.eu4wiki.com/Ruler#Deaths
If you don't have any good modifiers for stability cost then I'd avoid using your ruler (or heir) as a general, unless they're terrible, like Castille's starting ruler and heir.
A further piece of advice is to get a stability cost modifier. My usual go to for this is under religious ideas(http://www.eu4wiki.com/Idea_groups#Religious) as Church Attendance Day.
If you want to avoid this entirely, switch to a republic. They won't suffer the stability hit and you'll also always get a leader with average stats(e.g. 1/4/1). There are events for switching for certain nations or you can let legitimacy fall low enough to spawn rebels.