Remember - there are no "Compass Directions" in SP. Games are played right to left, the top of the screen is "top" (not North) and the bottom "down", not South. Unless a scenario designer has annotated the map of course

.
Retreaters will head for their own map edge (left or right), by the
fastest route in MP expended - so will head for a nearby road, for example, if it computes that this will get it there. So the retreat direction could go off at an initial diagonal, not straight to the rear.
Also - see the Deployment Menu section of the GG, Retreat/Rally hex sub-section. If there is a rally hex, then the retreater will head for that as an initial point, before heading off to the rear (if it is not rallied by then).
But a retreater will still try to take the
shortest route in MP to where it wants to go - if there are piles of wrecks, or stacks of troops in a hex, it may bypass the crowded hex for a more open one, especially for vehicles it will favour clear hexes over rough and wooded terrain and nearby road routes to the rear. That sometimes means a router will try to retreat across the front of a crowd of units or piles of wrecks, heading for the clear hexes at the side of the blob.
It'll
try not to rout through enemy troops - but if it decides the best (least MP) route goes through some, then it will (they might not have shots left, after all!). Routers are more likely to simply "bull through" enemy than retreaters. And routers with OK status enemy in the same or adjacent hex may just simply surrender instead of routing.
But ultimately - retreaters go by the least MP route to where they want to be (rally hex first and then base edge), and there is absolutely no computation in there about routes that will be free from enemy fire, and only marginal note of enemy forces as hindrances to MP expended.
If you are deep in the enemy rear and the straight path to the base has enemy blocking it - then you
may want to try putting a rally hex for those formations somewhere "radical" - in clear ground well away from the enemy, maybe even more towards the enemy baseline. In placing same - remember that they will go there, and then towards own baseline if not stopped, so that has to be part of your placement strategy.
Me - I don't generally bother with rally hexes, I leave it at the game default and simply just fight in a manner that my forces do not need to retreat (if it becomes necessary) through the enemy lines, other than maybe a throw-away section of armoured cars or suchlike that are trying to run down his gun-line, say. But they may well be useful if you have blocked the enemy by going around him - and he is thus now also blocking
you 
.
Cheers
Andy