Fixed issue of all threads not closing on exiting client