IPC, inter process communication, get your thread to let your application know if it successfully attached and executed the procedure/function if all is good then close the injector else keep it open, While timers and on button click events are fine they are not really closing the app on a success, instead they will close app no matter what happends