change Window.close to switch back to the original window. Refactored Window to invert dependencies