code: def shutdown(self):
          
          if not self.is_running():
              self.logger.warn('ZAP is not running.')
              return
  
          self.logger.debug('Shutting down ZAP.')
          self.zap.core.shutdown()
  
          timeout_time = time.time() + self.timeout
          while self.is_running():
              if time.time() > timeout_time:
                  raise ZAPError('Timed out waiting for ZAP to shutdown.')
              time.sleep(2)
  
          self.logger.debug('ZAP shutdown successfully.')
docs: Shutdown ZAP.