Timing stability of millisecond pulsars and prospects for gravitational-wave detection