I’m making a GUI application and I want to use matplotlib to display some plots. I have structured my code like that: The problem I have is that when the toplevel window is displayed and then closed, the program won’t close correctly even after closing the root window. Is there a way to fix this?? Answer As Henry Yik pointed