Prevent the program from closing unrelated windows such as "task switching", "start menu". I did that by confirming that the window that the program will close is appearing on the list of windows. So I also added a timer for updating the list of windows, that will prevent the