scripts: document and add example

Document new functionality for terminating threads and add example usage of
the new threadid and nthreads table members.