My general process?
Start writing. Get an idea that has absolutely nothing to do with what I'm writing. Reach across my desk and set a timer for five minutes. Hate the idea for existing. Hate my brain for creating it. Hate my inability to focus. Hate myself for wanting to run away from the work that's right in front of me, the writing that I get paid to do. Get angry at the idea for feeding on my hate, and growing stronger and more appealing in the process. Wonder if it really is the idea's actually growing stronger or my growing weaker. Notice that the timer's gone off. Get back to work.
Two or three days/hours later, lose track of time. Recover sense of it. Discover I've written a draft of the idea. Remind myself that I should be more alarmed about that, but try not to dwell on the implications. Admire the idea's tenacity. Decide to give it twenty-five minutes each day until it grows tired of me. Five or six months/weeks/days later, get to the point where we don't bother each other anymore. Get back to work.
Sometimes, there are exceptions. There used to be more, but except for the occasional scraps of terrible poetry on my personal blog, I don't post or publish fiction these days.