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.