@Override
 public void close() throws IOException {
   synchronized (this) {
     try {
       if (isConnected()) {
         try {
           channelHandler
               .executeRequest(new UnregisterModelControllerRequest(), null)
               .getResult()
               .await();
         } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
         }
       }
     } finally {
       try {
         connectionManager.shutdown();
       } finally {
         super.close();
       }
     }
   }
 }