Normally spawned child process would not end even when the parent process exits. To kill the child process, the child process pid need to be recorded somewhere (in a file to allow the value to exist even when the parent process exits) and the same can be used to kill the child process when required.