test: Don’t try to close nil stream

If errors occur while creating the stream, it will be nil, so close
after checking the error.

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>
Merge pull request #633 from flynn/test-nil-stream

test: Don’t try to close nil stream