fix(streams): close the filedescriptor when the stream ends

I wonder if it would be better to throw if someone tries to write to a closed stream?