pool: Controlled termination of thread pools during pool shutdown

Also adds additional dependencies between pool components to control
the shutdown order.

Target: trunk
Require-notes: yes
Require-book: no
Acked-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Patch: http://rb.dcache.org/r/6789/