Interesting question! the answer is technical and related to behavioral reinforcement.
If a person actually does not perform the ritual any longer, the distressing thoughts (obsessions) will tend to briefly get worse before they go away entirely. The reason they go away is partly because they are not reinforced by the relief of the ritual. Response prevention is the name of this approach.