ah ok, yes, changing from trusted to untrusted and then re-starting the build caused a problem. The system assumes that a build that previously executed without error can be safely restarted without performing certain bounds checks. Changing the trusted flag to false would cause a linting error on restart. So it looks like you found an edge case where that assumption does not hold true, resulting in an uncaught exception in the code.
Uncaught exceptions, because they are not expected, can put a build in an inconsistent state and therefore prevent it from being cancelled. You can go into the database and run the following command to resolve:
update builds set build_status = 'error'