A good question was recently received:
What are the particulars on attacking/defending with stacked units?
Stack combat can be handled one unit at a time as per the rules.
Should a unit in a stack retreat before all units in the stack have been attacked, you could assign shaken status to the unit(s) remaining. That would give a + 2 modifier for any attacker if remaining units are attacked in that turn. This would simulate lowered morale caused by a nearby friendly unit retreating.