Close a stream properly in test.test_pulldom. Closes issue #11550. Thanks to Ben Hayden for some inspiration on the solution.