Apparently it can take a moment between closing a tempfile marked as DELETE_ON_CLOSE and it actually being deleted. During that time the file is inaccessible. Thus just skip deleting the temp file on windows.
options