Fix writing of end marker for BSON objects/array in BsonSerializer.