Dev thought: Seems like a race condition when the Python env is garbage collecting at the end of the experiment; pyglet.gl has already been removed by Python prior to __del__ method being called. Explicit check for this in the class __del__ could fix it.