code: def stop(self, timeout=None):
          
          assert self.scan_id is not None, 'No scan_id has been set'
  
          #
          #   Simple stop
          #
          if timeout is None:
              url = '/scans/%s/stop' % self.scan_id
              self.conn.send_request(url, method='GET')
              return
  
          #
          #   Stop with timeout
          #
          self.stop()
  
          for _ in xrange(timeout):
              time.sleep(1)
  
              is_running = self.get_status()['is_running']
              if not is_running:
                  return
  
          msg = 'Failed to stop the scan in %s seconds'
          raise ScanStopTimeoutException(msg % timeout)
docs: Send the GET request required to stop the scan
  
          If timeout is not specified we just send the request and return. When
          it is the method will wait for (at most) :timeout: seconds until the
          scan changes it's status/stops. If the timeout is reached then an
          exception is raised.
  
          :param timeout: The timeout in seconds
          :return: None, an exception is raised if the timeout is exceeded