Updated logic to terminate the monitor process !!!