Trying to consciously focus on what one is doing rather than thinking about it can help.
I've heard in some cultures men tie a string around the genitalia & thread it into their pockets. When unwanted arises, the string is pulled & its suppose to get rid of it! do not recommend this, but this illustration helps place this perpetual problem into perspective. Cooling & tensing the muscles can help.