British naval units surviving after British surrender remain in port. The city next to the port switches to axis control and any unoccupied ports switch to axis control, however ports themselves do not change until the city is occupied, in at least some cases even a turn or two after the British ships leave.
In Egypt the axis can move up, attack the ship in port, back out of the city, and the ship will remain in port allowing the axis to attack again the next turn.
In Gibraltar and Malta the axis needs to send a unit, either amphibiously or an air unit, and occupy the city before the naval units will leave. This gets expensive, an amphip assault in, with a naval unit defending, and a transport out, or a operational air unit in and operational movement out.
Is this a bug or a feature? :)