Re-applying Nicolas' fix for glut close func.