Currently (1.3.1) when the settlement you are in is raided, you can Sally Out to meet the attackers, If you then retreat all your troops and retreat via the TAB menu, the game forces you to do another Sally Out battle instead of allowing you to resume the siege. This seems wrong, you should be able to wait for the attackers to assault the castle after retreating from a Sally Out.
update: You CAN, but you have to select the "LEAVE" option on the final menu, which is not at all clear.
update: You CAN, but you have to select the "LEAVE" option on the final menu, which is not at all clear.