code: def exit(self, code=None, msg=None):
          
          # add exit message to message.tc file and log
          if msg is not None:
              if code in [0, 3] or (code is None and self.exit_code in [0, 3]):
                  self.log.info(msg)
              else:
                  self.log.error(msg)
              self.message_tc(msg)
  
          if code is None:
              code = self.exit_code
          elif code in [0, 1, 3]:
              pass
          else:
              self.log.error(u'Invalid exit code')
              code = 1
  
          if self.default_args.tc_aot_enabled:
              # push exit message
              self.playbook.aot_rpush(code)
  
          self.log.info(u'Exit Code: {}'.format(code))
          sys.exit(code)
docs: Application exit method with proper exit code
  
          The method will run the Python standard sys.exit() with the exit code
          previously defined via :py:meth:`~tcex.tcex.TcEx.exit_code` or provided
          during the call of this method.
  
          Args:
              code (Optional [integer]): The exit code value for the app.
              msg (Optional [string]): A message to log and add to message tc output.