Imagine the following scenario:
You're happily hacking away at your latest project. Things are coming together and you're slamming out some awesome features in a caffeine-fueled haze. Suddenly, your boss appears with a deadly statement: "I was thinking...."
I don't even need to finish that statement. We've all been there. Alarm bells are going off in your head before he even finishes the first sentence. Best-case, it'll be a false alarm and won't result in extra work. Worst-case (and much more likely), you'll be up late for a week rebuilding the structure to add a feature that does nothing but stroke the boss' ego.
I like to call this the reverse eagle. The programmer has all their ducks in a row until an edict arrives from "on high." The edict is akin to an eagle swooping down and depositing an enormous duck (rather than stealing one). The rowed-up ducks are lost. The programmer now has to deal with both the scattered ducks (the now-lost project) and the new, out-of-place duck.
Unfortunately, there's no real way to prevent the reverse eagle. Once it's happened, the damage is done. You may be able to talk your boss out of it but the idea will still be there. Your best solution is to be proactive in ensuring that projects don't go out of scope, and that your boss is familiar with the intricacies of software development.