The connection to ZK here is closed in next line "nimbusLeadership.getNimbusLeaderAddress()". The "getNimbusLeaderAddress()" function has finally closed CuratorFramework calling "close();"