Window management with multiple displays and desktops
I don't have an external monitor to test this on, but you could look at an app called Swapp that purports to be able to swap the contents of an external screen onto your main display.  I'm not sure if it works with more than 1 external monitor, but in theory you might be able to switch to a 2nd desktop on your MBP, and swap the windows from an external monitor onto it, hopefully being able to repeat the trick with a 3rd monitor on a 3rd desktop space.

There is also Display maid which looks similar.

Both have free trials.

You could also try this relatively simple but manual trick to shove windows to another desktop space, either before removing your external monitors or after:

Enable Desktop Space control keys in System Preferences &gt; Keyboard &gt; Keyboard Shortcuts &gt; Mission Control, check the boxes as follows:



To move windows, click and hold on any window titlebar and hit Control+2, Control+1, or Control+3 to instantly bring the chosen window to the desktop corresponding to the keyboard shortcut