fix stop on non-empty dir or if keepEmptyDir is on