Fix thread starting and stopping.