added proper thread termination on window-close click