Checks if the process is running
If the posix extension is available, posix_getpgid() is used. Otherwise ps is used on UNIX-like systems and tasklist on Windows.
Ends the process gracefully
The signal SIGTERM is sent to the process. The gpg-agent process will end gracefully upon receiving the SIGTERM signal. Upon 3 consecutive SIGTERM signals the gpg-agent will forcefully shut down.
If the posix extension is available, posix_kill() is used. Otherwise kill is used on UNIX-like systems and taskkill is used in Windows.