Prevent exceptions after disconnecting