Terminating background thread which uses Synchronize

It seems like this ought to be simple, but so far a pleasing solution
has eluded me.  I have a class derived from TThread which uses
Synchronize to perform output to the screen.  If the user wants to
exit the main program while the secondary thread is running, I have to
terminate the thread, and then wait for it to actually quit before I
can allow the main program to shut down.  Failure to do this results
in the secondary thread attempting to synchronize with the main
program after it has already shut down.  Clearly a bad thing to do.

The natural way to do this seemed to be to use WaitFor, but that is
illegal since the thread uses Synchronize.  So, if anyone can tell me
the correct way for the main program to wait for the secondary thread
to actually teminate, I would appreciate it.