Added a possibility to define a call back on thread pool die.

Added a possibility to define a call back on thread pool die.