def METHOD_NAME(binding):
    binding.scan.set_state(SCAN_STATES['CANCELED'])
    cancel_scan_tasks(binding.task)
    if binding.scan.is_errata_scan():
        Scan.objects.filter(id=binding.scan.id).update(
            enabled=False,
        )
        binding.scan.enable_last_successfull()
        if binding.scan.base and binding.scan.base.is_in_progress():
            binding.scan.base.set_state(SCAN_STATES['CANCELED'])
    return binding.scan