REPORT-644 - Improve performance of serialization to disk (followup fix to ensure output stream is closed)