Updated the script to terminate the process