Colloquially it is a synonym, but technically the "Sin of Onan" for which it is named for is actually an instance of coitus interruptus.
"Onanism -- it's a hands-on job" -Ghost, ENTER THE MATRIX