ctest: Restore cleanup of load_command plugins

Restore `cmDynamicLoader` cleanup removed by commit c7d11a77e4 (ctest:
Remove outdated optimization of tests running ctest itself, 2024-10-16).
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 0765ff7..ceb7c58 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -54,6 +54,7 @@
 #include "cmCTestUpdateHandler.h"
 #include "cmCTestUploadHandler.h"
 #include "cmCommandLineArgument.h"
+#include "cmDynamicLoader.h"
 #include "cmExecutionStatus.h"
 #include "cmGeneratedFileStream.h"
 #include "cmGlobalGenerator.h"
@@ -3004,7 +3005,11 @@
 
 int cmCTest::RunCMakeAndTest()
 {
-  return this->Impl->BuildAndTest.Run();
+  int retv = this->Impl->BuildAndTest.Run();
+#ifndef CMAKE_BOOTSTRAP
+  cmDynamicLoader::FlushCache();
+#endif
+  return retv;
 }
 
 void cmCTest::SetNotesFiles(const std::string& notes)