Fix closedir crash

Related to issue: https://github.com/mawww/kakoune/issues/90

Not sure if this fits your code style, but it appears to fix the problem.