fixed SIGSEV error when disconnecting