Fix timer overflow

Cap timer to prevent possible integer overflow.

The magic value used is 2147483647 ms, 0x7FFFFFFF (7 with 7 F's behind) or 24.8 days which is the biggest 32-bit signed number available.

References: http://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values