From experience I know that if I order retreat to a nearby province when total morale is low my army will likely ignore my order and head to a far away province.
Three different scenarios are possible dependant on morale:
a) 0: Battle is over, game assigns a destination.
b) 0.01 to 0.5: Player can give order to abandon the battle, but the destination is out of his hand. Whatever province he chooses, the game will assign a destination as in a).
c) higher than 0.5: Player can give order to abandon the battle and determine the destination. Unreachable provinces (because of e.g. ZOCs) can't be choosen, the army stays in battle.
So I think b) happened to you.
If there are multiple stacks of armies some might choose different destinations. How does this work exactly? Is it completely random? Or is there any co-relation between morale and retreat distance?
One possibility: The combined morale of two armies in the battle is higher than 0.5, but one army is below 0.51. Manually abandoning the battle is possible, the higher morale army will go to the province of player's choice, the lower morale army has to go, where the game sends it to.
Another possibility: Each army has a morale higher than 0.5. But player hasn't selected all armies. This can happen by just clicking on the crossed swords. Now the selected army will leave the battle to the assigned province. The second (unselected) army stays in battle, possibly just one day. Then its morale is 0 and will be send automatically by the game to somewhere.
Is there a way to make sure that all of my armies retreat to one location?
If each army has a morale higher than 0.5, all armies are selected and each army has access to the destination, it should work.