Ensure that streams are closed