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. See Multiple Windows, for information about window configurations.
Save the state of the selected frame’s windows in register r
Save the state of all frames, including all their windows, in 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.