Close temporary file properly, otherwise it can't be unlinked on Windows.