'Stops the process gracefully or forcefully.
If ``handle`` is not given, uses the current `active process`.
By default first tries to stop the process gracefully. If the process
does not stop in 30 seconds, or ``kill`` argument is given a true value,
(see `Boolean arguments`) kills the process forcefully. Stops also all
the child processes of the originally started process.
Waits for the process to stop after terminating it. Returns a `result
object` containing information about the execution similarly as `Wait
For Process`.
On Unix-like machines graceful termination is done using ``TERM (15)``
signal and killing using ``KILL (9)``. Use `Send Signal To Process`
instead if you just want to send either of these signals without
waiting for the process to stop.
On Windows graceful termination is done using ``CTRL_BREAK_EVENT``
event and killing using Win32 API function ``TerminateProcess()``.
Examples:
| ${result} =                 | Terminate Process |     |
| Should Be Equal As Integers | ${result.rc}      | -15 | # On Unixes |
| Terminate Process           | myproc            | kill=true |
Limitations:
- Graceful termination is not supported on Windows by Jython nor by
Python versions prior to 2.7. Process is killed instead.
- Stopping the whole process group is not supported by Jython at all
nor by Python versions prior to 2.7 on Windows.
- On Windows forceful kill only stops the main process, not possible
child processes.
Automatically killing the process if termination fails as well as
returning a result object are new features in Robot Framework 2.8.2.
Terminating also possible child processes, including using
``CTRL_BREAK_EVENT`` on Windows, is new in Robot Framework 2.8.5.'

def terminate_process(self, handle=None, kill=False):

    process = self._processes[handle]
    if (not hasattr(process, 'terminate')):
        raise RuntimeError('Terminating    processes    is    not    supported    by    this    Python    version.')
    terminator = (self._kill if is_truthy(kill) else self._terminate)
    try:
        terminator(process)
    except OSError:
        if (not self._process_is_stopped(process, self.KILL_TIMEOUT)):
            raise
        logger.debug('Ignored    OSError    because    process    was    stopped.')
    return self._wait(process)
