When shutting down the controller the broker shuts down the controller and then closes the zookeeper connection. Closing the zookeeper connection results in ephemeral nodes being removed. It is currently critical that the zkClient is closed after the controller is shutdown, otherwise a controller election will not occur if the broker being shutdown is currently the controller.
We should consider resigning leadership explicitly in the controller rather than relying on the zookeeper client being closed. This would ensure that any changes in shutdown order cannot lead to periods where a broker's controller component is stopped while also maintaining leadership until the zkClient is closed.