Genesis 38:9 NLT

9 But Onan was not willing to have a child who would not be his own heir. So whenever he had intercourse with Tamar, he spilled the semen on the ground to keep her from having a baby who would belong to his brother.