There's a pattern I've encountered several times where I need to use a temp file/folder and have it cleaned up at some point later.
The natural thing to do here is to follow the patterns from "Robust Error Handling and Cleanup in ObjectScript" with a try/catch/pseudo-finally or a registered object to manage cleanup in the destructor. %Stream.File* also has a "RemoveOnClose" property that you can set - but use with care, as you could accidentally remove an important file, and this flag gets reset by calls to %Save() so you'll need to set it back to 1 after doing that.
There's one tricky case, though - suppose you need the temp file to survive in an enclosing stack level. e.g.:


.png)
.png)