better worker cleanup and better error handling on connection errors