code: def cleanup(self):
          
          if self.sock is not None:
              self.sock.close()
          if self.outfile is not None:
              self.outfile.close()
          if self.bar is not None:
              self.update_progress(complete=True)
docs: Release resources used during memory capture