private static void OnShutdown(object sender, EventArgs e) { lock (managedVtable) { // There may be object instances when shutting down if (vtableRefCount == 0 && comVtable != IntPtr.Zero) DisposeVtable(); } }