Use Stream#closed? if it's already defined.