Once again, getting Panda 3D working with C++

I set up a new project, created a main.cpp and copied this from the manual

#include "pandaFramework.h"
#include "pandaSystem.h"

PandaFramework framework;
 
int main(int argc, char *argv[])
{
  framework.open_framework(argc, argv);
  framework.set_window_title("My Panda3D Window");
  WindowFramework *window = framework.open_window();
  framework.main_loop();
  framework.close_framework();
  return (0);
}

which will result in

Unhandled exception at 0x004ca6ac in Simulation.exe: 0xC0000005: Access violation writing location 0x000fffff.

upon closing. The exception occurs when returning from main.

Edit:
The problem appears to be with

PandaFramework framework;

since it by itself (meaning no other code active) will generate the exception. I was guessing the runtime wants to see it destroyed before terminating the application, since it is/might be considered an unmanaged application, but the destructor for that class is virtual …