Ensure directory handle is closed on error return.

git-svn-id: svn://daper.net/moc/branches/2.5@2755 910807d9-36e0-0310-a014-e9ea483e2ba4