If running systemd, wrap that crap into a cgroup and force kill the whole process tree on exit. I've been doing it for years with badly behaving applications. On phone, from memory, may not be exactly what is needed:
systemd-run --user --pty --wait --collect -p TimeoutStopSec=5s -- "$@"