Your long-transaction section is a useful reminder that an apparently idle client can still hold back cleanup. A read-only first check is:
SELECT pid, usename, application_name, state,
now() - xact_start AS transaction_age,
wait_event_type, wait_event, left(query, 160) AS query
FROM pg_stat_activity
WHERE xact_start IS NOT NULL
ORDER BY xact_start;
A role may need pg_read_all_stats to see other sessions’ query text. I would review the owning application before terminating any session. Disclosure: I’m affiliated with SqlOtter; its SQL Editor can run this check against the target PostgreSQL connection.