Genesis 38:10

NLT
New Living Translation

10But the Lord considered it evil for Onan to deny a child to his dead brother. So the Lord took Onan’s life, too.