Sometimes gifted kids have trouble when they're confronted with a problem (especially a math problem) that they can't solve immediately. I suspect that they get used to seeing the solution immediately and internalize the idea that solving it immediately is how it's done. Sometimes they need to learn that you may have to think about a problem for some time before you can figure out a way to solve it.

My DD had this problem badly until recently. I've been working with her a lot, and have explained this idea to her many times. It's finally starting (starting!) to sink in. She doesn't give up immediately, but she still hasn't internalized the idea completely. For example, she's studying for the regional spelling bee. She didn't get "odyssey" or "arraignment" on the first attempts recently and said, "Maybe I'm not so good at spelling after all." This from a 9 year old who beat the middle school kids to win the local spelling bee!

Do you think your son could be shutting down because he feels intimidated?