Attempted to add control of closing of the window. Still needs some
work.