Ensure db connection is closed for retry_deferred