Genesis 38
7 Ref Er, Judah's firstborn, was wicked in the sight of Yahweh. Yahweh killed him.
8 Ref Judah said to Onan, "Go in to your brother's wife, and perform the duty of a husband's brother to her, and raise up seed to your brother."
9 Ref Onan knew that the seed wouldn't be his; and it happened, when he went in to his brother's wife, that he spilled it on the ground, lest he should give seed to his brother.
10 Ref The thing which he did was evil in the sight of Yahweh, and he killed him also.