Closes the stream. This is done by flushing the stream and then closing the underlying output stream.