now second thread quit when window is closed