Fixed a glitch after all windows close

Program now tracks open windows, and exits if there are no windows open.