Method called when handling signals

def _signal_handler(self, signum, frame):
        """ Method called when handling signals """
        if self._options.config:
            with open(self._options.config, "w") as cfg:
                yaml.dump(self._home_assistant_config(), cfg)
                print(
                    "Dumped home assistant configuration at",
                    self._options.config)
        self._connection.close()
        sys.exit(0)