Close fd again after opening with mkstemp

Fixes #155