when closing a window, open previously opened window