Close the output stream when storing