I know this had to be one of many big issues in the whole dictator or monarchy government model where there's one supreme commander/ruler who is in and of itself the entire government and who can appoint people to take on roles for him.
If the King goes mad what happens then? You can tell the king he's mad, that's treason and one of the royals will execute you for such a threat. I'm sure even royals would not be able to tell the king he's mad.
You also can't do anything about it, there's no other system but him, he's the embodiment of the government so there's no real process to go around him and replace him.
And you can't lead an attack on him to force him off because then you're making immediate enemies with the entire army and guards.
As far as I can tell the only sole way to remove him would be to lead an attack after all his men or most of the country has no longer recognized his authority but by then, and to get that far alone, there's no telling the damage he could do. Even just a week of insanity, being allowed to do whatever he wishes, hundreds can die and the country could be in ruins well before that even happens.
What exactly did monarchies and dictatorships do in this situation which I presume was not that rare, how did they handle this, was there any way of fixing the situation before it completely gets out of control?