Genesis 38:9-10King James Version (KJV)
9 And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother's wife, that he spilled it on the ground, lest that he should give seed to his brother.
10 And the thing which he did displeased the Lord: wherefore he slew him also.
Either way you read it, the Lord is kind of a dick. So Onan was supposed to knock up his brother's wife and when he decided he was killed. That is weird cult kind of shit.