By contrast if I turn the external monitor off in the control panel then all the windows are shuffled to fit on the current screen.
I would speculate that when the machine is undocked, something lower in the stack (X?) either doesn't notice this has happened, or doesn't send a xrandr reconfiguration event, or compiz doesn't respond to it in the same way it would handle a software-initiated reconfiguration.
I tested this on Natty with Unity (based on compiz). (See also bug 745112 about an external monitor at all on natty.)
I set up two side-by-side screens, using an external monitor connecting through the docking base and displayport.
I think undocked the laptop (without pressing the prepare-to-eject button), and removed it. I can see in the panel that the applications are still running but their windows are all off the screen. If I double click on say Chrome, which has multiple windows open, I get the exposé type view, but selecting one there does not bring it back on the screen.
By contrast if I turn the external monitor off in the control panel then all the windows are shuffled to fit on the current screen.
I would speculate that when the machine is undocked, something lower in the stack (X?) either doesn't notice this has happened, or doesn't send a xrandr reconfiguration event, or compiz doesn't respond to it in the same way it would handle a software-initiated reconfiguration.