GIMP_RUN_WITH_LAST_VALS must have the UI initialized too, for example when doing File -> Export <file>.