Reproduced on Windows:
If you get an exception when you try to handle the created file (rename, move etc.) you should unset the XMLWriter instance.
In other case you'll get an exception because the XMLWriter process holds access to this file.
<?php
$xml = new \XMLWriter();
$xml->openUri(...)
...
$xml->flush();
unset($xml); //important!