C++ plugin needs to know when Sketchup is closing

To invoke the logic without eval you can do something like this:

VALUE cAppObserver = rb_define_class_under(mSUEX_MyApp, "MyAppObserver", rb_cObject);
rb_define_method(cAppObserver ,"onQuit", VALUEFUNC(DoOnQuit), 0);

VALUE mSketchup = rb_const_get("Sketchup");

VALUE observer_instance = rb_class_new_instance(0, NULL, cAppObserver );
rb_funcall(mSketchup, rb_intern("add_observer"), 1, observer_instance);