First up, you cant kill a thread. You can politely ask it to terminate, but then it is upto the thread whether it will or not. Hence, why in the TThread.Execute you check Terminated, to see if it should continue or not.
Problem is, as soon as you think about the idea of calling TThread.Terminate, you can no longer use FreeOnTerminate, since, it is possible that the pointer to the thread is no longer valid.
Unless, the thread has a callback system for when it terminates, or it has a pointer to the pointer of itself, which it can set to nil, which is a little dodgy if you ask me. It all gets very messy very quickly.
So, how my code works is, the thread syncronizes with the main thread, and trys to find the GUI control it uses for display stuff. in this case, a TSynEdit control. If it isn't found, then the thread terminates itself.
So, all you have todo is free the TSynEdit control. The thread will terminate when its ready todo so.
Simple.
**EDIT* You may want to terminate the thread without freeing the TSynEdit. So, use a flag in TSynEdit like Enabled.
Set TSynEdit.Enabled := False. The thread can detect that and terminate itself, but, before it does, it should set TSynEdit.Enabled to True. (in the syncronized method)