I had to comment the "pygame.display.quit()" line for this to work for

Keith Nemitz:

This does not work perfectly under MacOSX. When returning from fullscreen mode, the window loses its title bar. And, if you select the window from the window menu in the menu bar, an invisible window pops up with a title bar, but it is non-active.