Move a close() call as to not mess upp errno