Fix thread destruction.