def METHOD_NAME(experiment):
    global _old_gamma
    # Restore display gamma if necessary
    if _old_gamma is not None:
        experiment.window.setGamma(_old_gamma)
    # This causes a (harmless) exception in some cases, so we catch it to
    # prevent confusion
    try:
        experiment.window.close()
    except:
        oslogger.error(
            u'An error occurred while closing the PsychoPy window.',
        )