Withdrawing is sort of hard if not done at the right moment, to me.
I try to withdraw my armies only when that historical general did it. In my new Hannibal AAR, (Which will come here within this month hopefully) the pitched battles were usually only fought till one of the armies withdrew, not until one was destroyed.... unless Hannibal had his way, like if the Roman commander was Fulvius, Flaminius, Varro, Sempronius and Minucius, just to name a few.

But to go on, sometimes I have to sacrifice a unit of my Italian allies to retreat and save my army to fight yet another day or in order to find a better position in which I can have a better position.
Or if you don't what to sacrifice a unit, try using your cavalry to charge the front lines and let your infantry get a good distance back and before you lose to many cavalrymen, and then pull them back and retreat in good order. In good order means try to retreat in something that resembles a battle formation just in case you need to turn around and fight. Retreating in good order allows you to be able to reinforce your retreating troops too, if they were caught by the enemy. Slingers/archers can make for a good covering force, since they have a long range and are quicker than most infantry.