Intermediate commit... Plan is to refine code that is executed when any thread exit. Current code is scatterd over multiple functions. For example, few lines in exit_wrapper, few in destructor, few in scheduler etc.