Closed cell is impermeable to water so in situation where it is used for the roof deck (rafters) and the roof sustains a leak, what would happen? The water will not show up on the underside of the roof/ceiling and will keep getting trapped on the surface of the foam (facing out) resulting in moisture/mold and rotting up the wood etc .
What is recommended is to use open for the roof so that you can spot a leak/fix it rather than hiding and not facing the fact that you have a roof leak.
Hope that helps.
Most roofs leak a tiny bit as they age -- the wind whips the water around - they dry out. Same if the foam is under it.
Most leaks are caused by bad installations -- ice dams - ridge vents -- condensation -- freezing heaters in unconditioned space. Spray foam eliminates most issues.
I always use plywood on roof decks.

