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?

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?

Spacepal needs macOS 14 or later and the Accessibility and Screen Recording permissions (see Setup).

Related guides

Summary

Written by Dan Bayer, developer of Spacepal. Last updated 2026-10-27.