It doesn’t matter how “Onanism” is “usually defined”. What matters is the context of the Biblical passage where the sin of Onan is discussed.
As previously mentioned, the context of Genesis 38 is that Onan failed to honor his family duties by providing offspring for his deceased brother. That passage doesn’t provide a blanket condemnation of withdrawing during sex.
What’s sad is that 100 years ago, every single Protestant denomination thought that birth control and onanism was absolutely depraved, the ultimate perversion of human nature, and a profound crime against nature. Margaret Sanger scared them all into thinking that the Catholics might outbreed them, and by 1950, Protestant literature was filled with novel interpretations about Onan, and proclaiming the wonders of birth control. By 1970, you could scarcely find a non-Catholic church proclaiming the Truth about birth control.