Close the stream when finshined encoding in encode(buffer, std::string)