private static void _CloseProgram() { // Unloading in reverse order try { CController.Close(); CVocaluxeServer.Close(); CGraphics.Close(); CThemes.Close(); CCover.Close(); CFonts.Close(); CBackgroundMusic.Close(); CWebcam.Close(); CDataBase.Close(); CVideo.Close(); CRecord.Close(); CSound.Close(); CDraw.Close(); } catch (Exception e) { CLog.LogError("Error during shutdown!", false, false, e); } GC.Collect(); // Do a GC run here before we close logs to have finalizers run try { CLog.Close(); // Do this last, so we get all log entries! } catch (Exception) {} Environment.Exit(Environment.ExitCode); }