Issue #3405976 by fago: Transaction autocommit during shutdown relies on unreliable object destruction order
(cherry picked from commit ae4b600b)
Closes #3405976