Don't clean up lockfiles if the directory doesn't exist

Fixes #20673.