Like their views on sodomy, they take this from the mythical Book of Genesis and the legend of Onan. Of course, they draw the wrong conclusion. Onan was not killed for what he did with his sperm but for the obligation he did not meet to his dead brother, an obligation which was cultural and does not currently exist to have incestuous relations with your brother's widow.