God was really angry with Onan for not doing the right thing for the brother that had died and so God killed Onan too.