Ok. Well. I did the shortcut version of telling you how to do this. So here we go. Ninuzzu and Tom is top notch authors. They have already made some code that is run on exit.
So. What you really should do first is. Search the table for <tablename>_exit routine. In this case you find that it is added already starting on line 265.
Sub Table1_Exit()
If B2SOn Then Controller.Stop
ExitUltraDMD
SaveHighScores
SaveValue cGameName, "Volume", 100*optMusicVolume
End Sub
You don't have to be an expert to see that save highscore and other things. If you where to add the code I told you in the end. This table would not save any highscores anymore.
Not what we wanted

They also call ExitUltraDMD - so it seems they have made their own sub routine for the stuff that we are trying to do.
Since it isn't directly in the script file itself. It has to be included from somewhere else. Since I'm a
VP nerd I know that Ninuzzu added Ultra_Options not that long time ago to
VP.
( One of the reasons to stay updated is that scripts can get updated - doesn't happen every day, but still)
So, in this case we would have to open the UltraDMD_Options.vbs in scripts folder and see what is done in the sub named ExitUltraDMD.
Function ExitUltraDMD
On Error Resume Next
If UltraDMD.IsRendering Then UltraDMD.CancelRendering
If Error.Number<>0 Then UltraDMD = Null:Exit Function
Dim WshShell:Set WshShell = CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\UltraDMD\color",DMDOldColor,"REG_SZ"
WshShell.RegWrite "HKCU\Software\UltraDMD\fullcolor",DMDOldFullColor,"REG_SZ"
UltraDMD = Null
End Function
To me it seems they are stopping UltraDMD and writing to registry. So, basically what we where trying to do in the first place.
So, you are saying that this table doesn't close UltraDMD on exit ? Is that when you load it normally or is that via a frontend ? or maybe both ?
IF however - when you search through a ultradmd table, and the <tablename>_exit routine isn't available in beforehand. My suggestion should still apply.
Btw. My table has originally 5521 lines. And the last line is 'End Sub'. You seem to have deleted some text in your attempt to implement what I told you.
You should make sure that you add empty line on 5522 and then use the code I provided.
Hope this makes sense.