Is the program you are trying to close running on the client or the server? I'd guess it's on the server, and TBH you shouldn't really be auto-closing OnDisconnected (it's too late anyway) - it might be just a network glitch, not a "proper" Close.
Likewise, if you're doing that on the client...