Only attempt to cancel query threads that are actually running.
Fix a number of issues with debugging on older versions of PPAS, and
ensure we can debug package initialisers.
Handle attempts to debug dropped functions gracefully.