def stop(self, save_options=True, save_log=True, save_macros=True, force=True):
        """Attempts to gracefully shut down fldigi.  Returns the error code.

        :Example:

        >>> import pyfldigi
        >>> app = pyfldigi.ApplicationMonitor()
        >>> app.start()
        >>> time.sleep(10)  # wait a bit
        >>> app.stop()
        """
        bitmask = int('0b{}{}{}'.format(int(save_macros), int(save_log), int(save_options)), 0)
        self.client.fldigi.terminate(bitmask)
        if self.process is not None:
            error_code = self.process.wait(timeout=2)
            if force is True:
                if error_code is None:
                    self.process.terminate()  # attempt to terminate
                    error_code = self.process.wait(timeout=2)
                    if error_code is None:
                        error_code = self.process.kill()
            self.process = None
            return error_code