make sure streams are properly closed in extractStream/extractArchive