When does assert fail? Running out of space?

I too had a similar problem when first trying to use setup_call_cleanup/3 (other post) but after spending an hour or two looking for examples in the SWI-Prolog source code on GitHub found several revealing examples, which are documented in the other post, and now I am quite comfortable using it.