added a change to allow for closing of the window when a 'stopWith' is reached