The example increments the value from plugin for each new vehicle spawned. That worked fine, so I guess you must be clearing the value somewhere, or talking to a different plugin class instance.
Yep, the latter - the plg member is not actually used, when the script connects, it invokes the creator method (plugin::get), and that creates its own local singleton object. You can change it to access the _M module object instead, and take the plugin class instance from there (but it probably needs to be changed to iref<plugin> plg
The crash is likely because of incorrect cleanup when the plugin unloads and leaves the singleton that destroys late.