Fixed not to sleep thread before it's terminated