Just one impromptu correction:
SICStus **does** conform here, however the top-level loop (out of scope of the standard) shows something different.
ICStus 4.9.0 (x86_64-linux-glibc2.28): Fri Dec 15 10:08:12 UTC 2023 Licensed to UlrichNeumerkel | ?- open('/tmp/myfile',write,S),close(S), close(S). ! Domain error in argument 1 of close/1 ! expected stream, but found '$stream'(127661962395680) ! goal: close('$stream'(127661962395680)) | ?- open('/tmp/myfile',write,S),close(S), catch(close(S),error(E,_),true). S = '$stream'(127661984026720), E = existence_error(stream,'$stream'(127661984026720)) ? ; no
So just the second query shows us what we want to see, but before SICStus produced this domain error (which now is found in the second argument of error/2)