When the AvailableModulesList is destroyed, it will wait for the current
module scanning job (running on a background thread) to complete. This
job will try to take the AvailableModulesList::lock when it completes,
so the lock must outlive the background thread.
When the result of find_if() is only compared to the container's end(),
the operation can normally be expressed more concisely using any_of(),
all_of(), or none_of().