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.
Change select timeout to 1 second.

Previously the worst case for exiting was 10 seconds after the signal arrival.
Close all databases as the last thing before exiting

...and keep mutexes locked to make sure they are not reopened by some
background thread.
Output messages when starting and exiting

...since our signal handlers are silent now.
Merge pull request #732 from jimis/sighandling

Avoid deadlocks and error messages when exiting