THREADKILL THREADKILL Halt execution of a thread Usage The threadkill function stops (or attempts to stop) execution of the given thread. It works only for functions defined in M-files (i.e., not for built in or imported functions), and it works by setting a flag that causes the thread to stop execution at the next available statement. The syntax for this function is threadkill(handle) where handle is the value returned by a threadnew call. Note that the threadkill function returns immediately. It is still your responsibility to call threadfree to free the thread you have halted. You cannot kill the main thread (thread id 1).