fix thread crash on exit osx / can call connect again after being disconnected