Manually free C++ class to avoid GC crashing