Handle build cancellation in VS2012.

The size of this change belies the difficulty of getting this approach to work.

Fixes GH-178