The streams used to read and write the message object in the example 4 were not closed. This commit fixes this error.