Solved functionality for closing and opening one window