Pulling out disconnect logic into a helper method.