Auto-translated
Is there a script that prevents a player's hero from fleeing a battle?
DenyAIHeroesFlee
SetAIHeroFleeControl
But this only applies to bots. You can only prevent a player's hero(es) from fleeing by removing towns with taverns or using the artifact Shackles of Inevitability.