Mask modifier not rendering
Ok, it seems that if a mask modifier is used with a subdivision surface modifier, the render and the viewport subdivisions have to be the same. I think the problem it's related to the cache of the baked simulation.

When I do that, the object renders correctly.