This process has saved me from an outage more than once.<p>I keep a dashboard of running pids, and get alerts when any of them take more than N minutes (excepting autovacuum). Once every few months I have to psql into prod and cancel one.
<a href="https://github.com/dalibo/pg_activity" rel="nofollow">https://github.com/dalibo/pg_activity</a> ('a top-like application for PostgreSQL server activity monitoring') is quite useful.