Adding cleand shutdown of pthreads.