Force garbage collection to finish up its background tasks: GC::Collect(); GC::WaitForPendingFinalizers();