Add support for `wait_command` using threads.