fixing up order of shutting down threads