Just to add a few comments to this discussion. In real life, what armies can and cannot do when they’re retreating is dictated by some of the general principles that govern ground warfare. (I’m leaving sea warfare and air warfare out of the picture for purposes of clarity.)
First: there’s the principle that an army can only fight to its front. Armies fight most effectively when the operate as a coordinated group, not as a bunch of individuals acting as they each see fit. From ancient times to (roughly) the era of short-range, unrifled, muzzle-loading firearms, this meant soldiers from one side disposing themselves in long lines facing towards the enemy troops, who were likewise disposed in long lines facing them. The two relevant points here is that the soldiers on each side are all doing the same thing (because as I’ve said armies function best as a coordinated group), and that they’re all facing the opposing forces (because soldiers, regardless of how they’re armed, can only use their weapon against people who are in front of them, which is why a military front is called a “front”). Things became more complicated when long-range rifled firearms arrived on the scene around the middle of the 19th century, and became even more complicated when the rate of fire of rifles became faster as breachloaders and then machine guns were developed. Those developments made massed infantry formations dangerously obsolete in many tactical situations – a point which WWI generals were surprisingly slow to grasp – but they didn’t alter the fact that the “front” concept was still applicable in land warfare. In WWII, the sheet size of the armies involved and the fact that some of them were mechanized to various degrees meant that “fronts” went from being tactical in scale to being strategic in scale. The classic example from WWII was the German-Russian conflict during the period from 1941 to roughly 1944: the zone of conflict was more or less linear, it stretched from northern to southern Europe, so it was quite appropriately called “the Eastern Front”.
Second: there’s the principle that defense tends to be stronger than attack because an attacking infantryman must (to put it simply) stand up and more into the open and expose himself to enemy fire in order to advance, whereas the defending infantryman can stay in his foxhole or crouch behind something or even lie on the ground while he’s pointing his weapon at the attackers. The attacker, in other words, is a physically larger target than the defender in terms of how much of his body is exposed to flying bullets, which is why there’s a rough rule of thumb saying that an attacker typically needs three times the numbers of the defender in order to take a position.
What does all this have to do with retreats? Because it all means that, generally speaking, an army can either fight or retreat but it can’t do both at the same time. At least not as a unified formation. The compromise method of having it both ways at the same time is for an army to divide itself into a covering force and a retreating force; this works to some extent, because it allows part of your army to escape, but the price to be paid is that the covering force will usually be annihilated. A good example is the Falaise campaign in France in 1944, in which the Germans were compressed into a pocket by the British to the north and the Americans to the west and to the south. The Germans formed a defensive perimeter and fought desperately to keep open the “Falaise gap” through which part of their army was trying to escape, while the Anglo-Americans were fighting just as desperately to link up in order to seal the gap – which they ultimately did, trapping and/or destroying the German forces that were still inside the pocket.