Here are two options for powering the Duet off either totally or partially when a print has finished:
1. Provide a separate 5V power supply as you have done, and use the PS_ON output to switch a relay or SSR that feeds AC mains to the PSU. Then you can use M81 to turn off the main power. This won't actually save much power on the Duet, because if your end-of-print script turns off all the heaters, fans and drives, then the power draw from 12V or 24V will be very low anyway. But it does turn off the main PSU. To turn the PSU on again, send M80.
2. Don't provide a separate 5V power supply, but enable the 5V internal regulator. Connect a relay or SSR to PS_ON as before, also connect a mains voltage push button in parallel with the AC terminals of the SSR. Put M80 right at the start of config.g. To turn the printer on, press the push button for long enough to start the Duet so that it runs the M80 command and turns the SSR on. To turn the Duet off, run M81. Also make sure there is no USB cable connected, else it will supply 5V USB power and keep the MCU on.
Some notes on the above:
1. PS_ON is an open drain output. You can connect the control input of an SSR between PS_ON and +3.3V, +5V or even +12V or +24V. Similarly for a mechanical relay board that has an optically isolated input. If you connect the coil of a mechanical relay directly between PS_ON and a positive supply, then you MUST connect a flyback diode in parallel with the relay coil.
2. The only risk to removing power abruptly is that if you have enabled logging and the log file has not been flushed, then you could end up with a lost cluster on the SD card. The M81 command flushes and closes the log file (and turns off logging), also the log file is flushed every 15 seconds when there are new entries to be written.