The cleanup method is called when a Bolt is being shut down and should clean up any resources that were opened. There’s no guarantee that this method will be called on the cluster: For instance, if the machine the task is running on blows up, there’s no way to invoke the method.
The cleanup method is intended when you run topologies in local mode (where a Storm cluster is simulated in the process), and you want to be able to run and kill many topologies without suffering any resource leaks.