Exiting out of a program through a menu option
<p>I need to say first and foremost, I am just learning Python.  </p>

<p>I am making a simple python program that has a menu option for exiting the program by using a function I called exit.  I have tried making the exit function just call break, but I am getting an error when the exit function is called.</p>

<p>Any help would be greatly appreciated.</p>

<p>Sorry for not posting code earlier....</p>

<pre><code>def exit():
    break


evade = evade_fw()

# Main program running dialogue
def main():  # menu goes here
    opt_list = [xsl_file,
                basic_loud_scan,
                fw_main,
                exit
                ]
</code></pre>

<p>Use the <code>sys.exit</code> method:</p>

<pre><code>import sys
def exit():
    sys.exit()
</code></pre>

<p>That's the proper way to terminate your program.</p>

<p>You can also use <code>os._exit</code> the same way.</p>

python menu exit