code: def end_scan(self):
          
          # TODO check states before/after
          self._set_state(self._STATE_GAP_END)
          self.api.ble_cmd_gap_end_procedure()
          self._wait_for_state(self._STATE_GAP_END)
  
          logger.debug('scanning completed')
          return self.scan_responses
docs: Ends an ongoing BLE scan started by :meth:`begin_scan`.
  
          Returns:
              a :class:`ScanResults` object containing the scan results.