Close output stream after processing is completed