Pretty sure you just want TimeConstrained:
TimeConstrained
TimeConstrained[ code, limit]
That will return as $Aborted, but you can also return a different failure case with the 3rd argument:
$Aborted
TimeConstrained[Do[i^2, {i, 1000000}], 1, $Failed]
Yes. That worked, thank you! Can someone confirm that Mathematica 10 is significantly less astute at PrimeQ than Mathematica 9? Timing[PrimeQ[(10^9600 78880-1)/3]] yields {7.265538,False} in 10 and {0.003482,False} in 9 (on a four-year-old iMac running Yosemite). That strikes me as a bug.