Windows pile onto the laptop when you unplug a monitor
When you unplug an external display, macOS moves its windows onto the laptop's screen, and when you plug it back in, it often doesn't move them back. There's no built-in setting that remembers which windows belonged to which monitor and desktop. You can reduce the mess with a few settings. To get a clean round trip, use a tool that saves the layout before you unplug and restores it when the display returns. Spacepal does this with "Prepare to Unplug Displays".
What does macOS do when you unplug a display?
Every window on the external display has to go somewhere, so macOS moves them to the built-in display. With several desktops, they're spread over the laptop's desktops in a way that's hard to predict, and windows may end up resized or stacked on top of each other. Some people see the same thing after sleep, when the Mac briefly loses track of a monitor.
When you reconnect, macOS sometimes moves windows back, but often it doesn't. It depends on the macOS version, the display and the cable or dock. Usually you end up dragging windows back one by one.
Which macOS settings make it better or worse?
- Displays have separate Spaces (System Settings > Desktop & Dock > Mission Control). On, each display has its own row of desktops. Off, desktops span all displays together. Most multi-monitor setups leave it on, but that means each display's desktops are lost when it's unplugged. Changing it takes effect after you log out.
- Assign To (Control-click an app in the Dock, then Options). "Desktop on Display 2" pins an app to the external display. When that display is gone, the app has nowhere to go and falls back to the laptop.
- Arrangement (System Settings > Displays > Arrange). Keeping the same arrangement and main display between sessions helps macOS recognise the setup when you reconnect.
None of these saves where windows were. macOS has no "eject" step for displays the way it has for disks.
How does Spacepal handle unplugging?
Spacepal has two features for this. Both are in the menu and in Settings, Windows.
Before you unplug: Prepare to Unplug Displays
When more than one display is connected, the Spacepal menu shows Prepare to Unplug Displays (also available as spacepal://eject). It first saves the current layout. Then it moves each external display's windows to the built-in display's Space in the same position, so the windows from the external display's first desktop go to the laptop's first desktop, and so on. If the laptop has fewer desktops, the extra windows go to its last one. You'll see how many windows were moved and that it's safe to unplug.
When you plug back in: put windows back
Spacepal saves a separate layout for each combination of displays. When a display is reconnected, it restores the layout it last saw for that combination and moves windows back to their Spaces on the external display. This is the "Put windows back when an external display is reconnected" setting, on by default.
You can also save and restore layouts by hand with spacepal://save-layout and spacepal://restore-layout (see URL scheme).
What are the limits?
- Full-screen windows aren't moved. Leave full screen first if you want them moved.
- Windows are matched by app and title. Windows whose titles change may come back in a different order.
- Putting windows back uses a direct window-server move that works on macOS 14.0 to 14.4 and on 26.4 and later. On the versions in between (most of macOS 15 and early 26), windows that are not in front stay where they are; you can still move the front window with ⌃⌥⇧ plus a number.
- Space names and colours are tied to each Space, so they come back with the display's desktops. If they look wrong, see Troubleshooting.
Spacepal needs macOS 14 or later and the Accessibility and Screen Recording permissions (see Setup).
Related guides
- Why windows open on the wrong desktop after a restart
- The Mission Control settings power users change
Summary
- Unplugging a display makes macOS move its windows to the laptop, and reconnecting often doesn't move them back.
- "Displays have separate Spaces", Assign To and a stable display arrangement affect what happens, but macOS never saves a layout.
- Spacepal's "Prepare to Unplug Displays" saves the layout and moves windows desktop by desktop to the laptop.
- On reconnect, Spacepal restores the layout for that display combination automatically.
Written by Dan Bayer, developer of Spacepal. Last updated 2026-10-27.