code: def stop_sync(self):
          
  
          if self.scanning:
              self.stop_scan()
  
          # Make a copy since this will change size as we disconnect
          con_copy = copy.copy(self._connections)
  
          for _, context in con_copy.items():
              self.disconnect_sync(context['connection_id'])
  
          self._command_task.stop()
          self._stream.stop()
          self._serial_port.close()
  
          self.stopped = True
docs: Safely stop this BLED112 instance without leaving it in a weird state