Generally, if you run a monster realistically (ei it doesn't want to die and panics if severely hurt) instead of cinematically (ei it fights until the heroes deliver the killing blow), the PC's will gain a huge advantage.
Tactically speaking, a monster should flee if a) it can do so without taking serious damage, and b) if its advantage is detiriorating with time. In general, things that can teleport away should flee as soon as they get one good lick in, especially if they also can regenerate or fast heal. Anything that can regenerate can gain an advantage by creating delays. Spell casters should flee early rather than latter, taking time to use scrolls and potions or simply waiting a day to get thier best spells back. Slow moving creatures should never bother fleeing. Mounted creatures probably always should flee as soon as they take a good hit. Creatures in melee _probably_ should never bother fleeing. Creatures unable to escape los in a single round should _probably_ never bother fleeing.
Intelligent foes should have a strategy for flight - bar the door, flee down a corridor containing a trap that can be avoided if you know where it is, release a monster behind them, hook up with allies, etc. Otherwise it is just not going to work that well.