Wait for lock file to release before returning