Wordfence aborts the scan when PHP stops script execution after 30 seconds. The plugin splits the scan into stages, each stage must finish before the timeout.
If the site contains many files, slow disk, or low PHP limits, a stage exceeds the limit and Wordfence reports a failure.