Make it ok to call terminate_threads twice.