You could say that. God found it detestable.
Genesis 38:7-10 (KJV)
But Er, Judahs firstborn, was evil in the sight of the LORD, so the LORD took his life.And Judah said unto Onan, Go in unto thy brother's wife, and marry her, and raise up seed to thy brother.
And Onan knew that the seed should not be his; and it came to pass, when he went in unto his brother's wife, that he spilled it on the ground, lest that he should give seed to his brother.
And the thing which he did displeased the LORD: wherefore he slew him also.