An even simpler alternative is to use a std::thread member variable in the MFC application class instead of a HANDLE. Of course the thread would still need to be told it is time to terminate. The advantage here is that only the native C++ methods are used to wait for the thread to end. So using your example (assuming MFC SDI), the code to start the thread could look like this -
void CSDIThreadEndView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CSDIThreadEndApp* pApp = (CSDIThreadEndApp*)AfxGetApp();
pApp->m_stdThread = std::thread(&CSDIThreadEndDoc::SomeMethod, GetDocument());
CRichEditView::OnLButtonDblClk(nFlags, point);
}
and the application class ExitInstance function could contain -
int CSDIThreadEndApp::ExitInstance()
{
if (m_stdThread.joinable())
m_stdThread.join();
// rest of ExitInstance function
}