Genesis 38:9-10
Genesis 38:9-10 ESV
But Onan knew that the offspring would not be his. So whenever he went in to his brother’s wife he would waste the semen on the ground, so as not to give offspring to his brother. And what he did was wicked in the sight of the LORD, and he put him to death also.