This is a painful and complicated issue, which triggers heated discussions from time to time. Many would tell you that you should never terminate thread; and a thread should gracefully terminate itself (just exit), after some polling of some flag (in shared data) which would give the thread an order to exit. But I rather say "never say 'never'"; unfortunately, there are whole big fields of engineering where such things are totally infeasible. I would say more: authors of OS purely recognize existence of such fields.
Please see my past answer:
Close correcly the thread inside a dll[
^].
Even if you won't use it, it will give you the idea on how serious this seemingly simple topic is.
As I don't know your application, I can first advise the cooperative termination described in first paragraph. If it cannot work for you, I can even mention
really dirty thing: a call to
TerminateThread
. Yes, it is dirty and strongly discouraged, but if the design of your thread does not allow simple cooperative termination you have one more
excuse: if this is the last thing your application does, you won't have to deal with the possibly bad consequences of this call.
—SAP.S.: It is very likely that this post will be down-voted. I would advise you to not pay attention for that. This topic is generally poorly understood.