adding teardown of threads when the window is closed...