diff --git a/patroni/__init__.py b/patroni/__init__.py
index <HASH>..<HASH> 100644
--- a/patroni/__init__.py
+++ b/patroni/__init__.py
@@ -159,7 +159,10 @@ class Patroni(object):
             self.api.shutdown()
         except Exception:
             logger.exception('Exception during RestApi.shutdown')
-        self.ha.shutdown()
+        try:
+            self.ha.shutdown()
+        except Exception:
+            logger.exception('Exception during Ha.shutdown')
         self.logger.shutdown()
 
 
diff --git a/tests/test_patroni.py b/tests/test_patroni.py
index <HASH>..<HASH> 100644
--- a/tests/test_patroni.py
+++ b/tests/test_patroni.py
@@ -174,6 +174,7 @@ class TestPatroni(unittest.TestCase):
     @patch.object(Thread, 'join', Mock())
     def test_shutdown(self):
         self.p.api.shutdown = Mock(side_effect=Exception)
+        self.p.ha.shutdown = Mock(side_effect=Exception)
         self.p.shutdown()
 
     def test_check_psycopg2(self):
Handle exception from Ha.shutdown (#<I>)

During the shutdown Patroni is trying to update its status in the DCS.

If the DCS is inaccessible an exception might be raised. Lack of exception handling prevents logger thread from stopping.



Fixes <URL>