Fix for stack overflow after disconnecting a few million times