This, gives the understanding of the Church in 1822, very clearly.
(From Denzenger 43 edition # 2715, p. 558)
Pontificate of Pope Pius VII:
Response of the Sacred Penitentiary, April 23, 1822, concerning Onanism:
On Practice of Onanism wlthin Marriage
Question: Is it possible for a pious wife to permit her husband to approach her when she knows from experience that he conducts himself in the abominable manner of Onan …, especially if, by refusing, the wife exposes herself to the danger of violence or she fears the husband might have recourse to prostitutes?
Response: Since in the present case, the woman, for her part, indeed does nothing against nature and practices what is licit, the entire disorder of the act comes from the malice of the man, who, instead of consummating [the act], withdraws himself and ejaculates outside the vagina: if, therefore, after due admonitions, the wife achieves nothing, and the husband still insists, threatening beatings or death or other serious violence, the wife (as approved theologians teach) will be able to offer herself passively without sin since in these circumstances she is simply permitting the sin of her husband and for a grave reason, which excuses her, for charity, which would require her to prevent (the act), does not oblige her [if connected] with such harm.