Stabilize termination process.

 - Recent versions of ZMQ library implicitly spawn internal IO threads
   when creating context objects (the number of threads is
   configurable).  Those threads should be destroyed explicitly,
   otherwise the termination process will leave "zombie" threads.

 - Removed time-out checks in safeexec().  It is not much useful since
   we do asynchronous IO now, and signal-based hacking is not portable.