thread commands and kill when finished