Fix deadlock in cf-serverd, see redmine #2864.

Logging is removed from the signal handler until it is reimplemented as
reentrant (now it calls vasprintf() which calls malloc(), which is not
reentrant).

Also marked exit(0) in the agent for future removal for the same reasons.
(cherry picked from commit 54f2dd564e62d27c99f51f177eab9f3cb9fe88da)
Change select timeout to 1 second.

Previously the worst case for exiting was 10 seconds after the signal arrival.
(cherry picked from commit 5aa0137a390907e0d2116200a7f9fa44f7e8e0b9)
Close all databases as the last thing before exiting

...and keep mutexes locked to make sure they are not reopened by some
background thread.
(cherry picked from commit baf2670ff40bc7fffc3560a1f5426cdfe5e3f647)
Output messages when starting and exiting

...since our signal handlers are silent now.
(cherry picked from commit c34fe052e856f13f86d6938f5fc66496098d9711)