Cancel currently running connecting thread when exiting