Close connection after syncing (#5507).