Saving Window Configurations in Registers

You can save the window configuration of the selected frame in a
register, or even the configuration of all windows in all frames, and
restore the configuration later.

C-x r w r Save the state of the selected frame's windows in
register r (window-configuration-to-register).

C-x r f r Save the state of all frames, including all their
windows, in register r (frame-configuration-to-register).

Use C-x r j r to restore a window or frame configuration. This is
the same command used to restore a cursor position. When you restore a
frame configuration, any existing frames not included in the
configuration become invisible. If you wish to delete these frames
instead, use C-u C-x r j r.