Are you trying to do this as an additional application for some game and running this ahk script before the games starts?
If you are, and you have a sleep in the script long enough to wait until the process is surely running before you try to kill it, you might try something like this in your loop that checks:
Process, Exist, process.exe
if(!errorlevel)
Process, Close, process.exe