fix the error when you close turtle screen in your own main loop
wn = turtle.Screen()
while True:
# just add the try & except to fix it, then it will work without error
try:
# all of the main loop code and the screen update:
wn.update()
except:
break