Code to fix clients not disconnecting sometimes