Postgres doesn't always notice when the web server shuts down. Some connections and queries can linger for many minutes or hours depending on exactly what they're doing.
Explicitly closing the connection prior to shutdown helps in at least some cases.
Changes
New shutdown listener that slams closed any connection that's been open for more than two seconds (to avoid interfering with DB connections related to the shutdown itself)
Avoid moving pipeline jobs to ERROR state if the error is encountered during shutdown, as it's likely it's caused by slamming the DB connection closed and we want to restart the job
Easier mechanism for registering simple shutdown listeners
Convert a few shutdown listeners to the new registration mechanism
Rationale
Postgres doesn't always notice when the web server shuts down. Some connections and queries can linger for many minutes or hours depending on exactly what they're doing.
Explicitly closing the connection prior to shutdown helps in at least some cases.
Changes