Genesis 38:9 Holman Christian Standard Bible (HCSB)

But Onan knew that the offspring would not be his, so whenever he slept with his brother’s wife, he released his semen on the ground so that he would not produce offspring for his brother.

Genesis 38

Genesis 38:1-12