forgot to close dir and return value

Signed-off-by: Leo Bärring <leo.barring@gmail.com>