Genesis 38:9-10
Genesis 38:9-10 NCV
But Onan knew that the children would not belong to him, so when he was supposed to have sexual relations with Tamar he did not complete the sex act. This made it impossible for Tamar to become pregnant and for Er to have descendants. The LORD was displeased by this wicked thing Onan had done, so the LORD killed Onan also.