about the treatment of closed streams.
Closed streams are still of the form a stream. Thus any attempt to use them any further will either lead to
- an existence error
?- open('/tmp/myfile',write,S),close(S), close(S). existence_error(stream, ...).
- failure, in case of a query about it
?- open('/tmp/myfile',write,S), close(S), current_input(S). false.
A domain error is only appropriate if the term can never be a stream-term. This indeed depends on an implementation which has here some freedom see 7.10.2.1.
?- close(1+1). domain_error(stream_or_alias,1+1). % provided 1+1 is not chosen ...