Yes. It’s called onanism, for Onan, son of Judah.
And Juda took a wife for Her his firstborn, whose name was Thamar. And Her, the firstborn of Juda, was wicked in the sight of the Lord: and was slain by him.  Juda, therefore said to Onan his son: Go in to thy brother’s wife and marry her, that thou mayst raise seed to thy brother.  He knowing that the children should not be his, when he went in to his brother’s wife, spilled his seed upon the ground, lest children should be born in his brother’s name.  And therefore the Lord slew him, because he did a detestable thing.