 Hey everybody, I just want to do a quick video to answer one of the questions I get so often on my YouTube channel is why am I getting this one weird error when I close my game? So let me show you what that looks like. So if I run this, this is just a little projectile motion. How can I put it? You know a little demo I put together the other day, so it just works like this. This is a typical turtle graphics window. Now when I close it, watch what happens. You're going to get this big long error message. It doesn't really mean anything, just means something went wrong. The game's over. I don't know why people are concerned about it, but people are. So let's go ahead and fix this. And so what I'm going to do is I'm going to go ahead and create a quit function. I've actually already created that part of it. I'm going to get rid of that because I was practicing earlier. It took me a long time to figure this out actually. So I got to do a couple things. So basically the error is caused because I've closed the window, but this while true loop is actually still running, because it's multi-threaded and different things are going on asynchronously. So what I have to do is I have to make sure that this loop ends. So to do that, I'm going to go ahead and create a new variable. I'm going to call it running. I'm going to make it equal to true. So I'm going to put here while running. Now I'm just going to test that because this is a good programming practice. I made a change, especially if you're a beginner. You make a change, you test it, see if everything's working the same way. Same error, which is what I expected. So what I'm going to do is I'm going to create a method, and I'm just going to put that here. I'm going to call it quit with the entry parentheses. And what I want to do is when I quit, I'm going to change running from true to false. So because this is a global variable, I have to put global here, and I'm going to be changing it. And I do have a video about that, so if you're not sure what that means. And I'm going to say running equals false. So then I need to do on my keyboard on key press. So when I press, I'm going to use the Q button. So when I press Q, it's going to change running from true to false. This isn't everything, but this is a start. So I'm going to go ahead and run that. It's still working. I'm going to hit Q. And you can see here, game stopped, which is partly what we wanted, but it's not everything we wanted. So what's happened is I've got to this line here, win.mainLoop, and it's still running. Win main loop keeps everything open. Let's go ahead and try it again, see what happens. And I'm going to press Q, and the window closes with no problems. Now you might have to actually add win.buy here, but I think it's pretty, it might be optional. But if you add it, it doesn't hurt. And so we'll test that. And there you go. That solves everybody's problem. I hope you guys are happy. So let me review that real, real quick. Okay. So I had to make my main loop use a variable that can be changed. So I used running. So while running, because that makes sense. So I start out, it's true. Then I set a command so that when I press the Q, it will change running from true to false. And then once that happens, this whole loop stops and the program would actually end. Again, I think it's probably a good idea to put win.buy just in case. It might be a difference between operating systems. It might not close quite correctly, but that will close the window for you the way that you want it for sure. Okay. So let's see. One, two, three, four, five lines of code plus one line changed. There you have it. Enjoy.