@JGoldman10,
He was not engaged in self-stimulation, which is the very definition of masturbation. He was actually engaged in sexual intercourse with his wife, then withdrew himself to ejaculate outside of her vagina. His purpose was to avoid making her pregnant,
not to give himself pleasure. A different biblical argument against masturbation can be made by citing New Testament scriptures that condemn impure thoughts.
By the way, I commend you for your ability to maintain self-control.