def ev_exit(): global status if status["text"] == "Playing game": if mb.askyesno("Quitting", "Do you want to save the game before quitting?"): ev_save() top.quit()