Genesis 38:8-10
Genesis 38:8-10 MSG
So Judah told Onan, “Go and sleep with your brother’s widow; it’s the duty of a brother-in-law to keep your brother’s line alive.” But Onan knew that the child wouldn’t be his, so whenever he slept with his brother’s widow he spilled his semen on the ground so he wouldn’t produce a child for his brother. GOD was much offended by what he did and also took his life.