I have coded a program in Win32 API which essentially a information gathering tool. there is this dialog in which the user is supposed to enter info. A separate thread is spawned which creates a process running another executable in the background. Now the question is if the user clicks cancel in the middle the program is supposed to exit and delete the directory which contains the background executable. I have tried both the terminateprocess and the exitprocess to stop the background thread and then call the function i have written to delete the folder. currently all the files in folder delete except the background exe, hence the folder is deleted as well.