If you want to open a new file at the end of the code then just write a custom macro and place it in your profiles macro folder. Custom macros are from m101 up but some are already used by wizards so check in the macro folder first to see you are not using a number thats already taken.
In your macro you would just have
Loadfile("c:\Mach3\gcode\folder2\program5.nc)
then you would name it and save it in your macro folder, the name would be your chosen m number followed by m1s, eg m101.m1s
When you called m101 from code or MDI it should do your macro and load the code.
For the M8 you can either set up an output and enable that output on the Ports and Pins, Spindle Setup page or if you wished you could write your own M8, if you do that you will also need to write your own M9.
You would need a custom M8 if you were wanting to activate several outputs from the M8 command, the macro would contain something like this
ActivateSignal (OutPut1)
ActivateSignal (OutPut3)
Your M9 would need
DeActivateSignal (OutPut1)
DeActivateSignal (OutPut3)
Hood