Make sure that stream's close() method is called.