mkstemp() returns and OS file descriptor - it has to be explicitly closed before the file can be removed.