OOIION-1756 Terminate high availability agent thread safely