Optimise lockClosure when n_capabilities == 1; fixes #693

Based on a patch from Yuras Shumovich.