For what it is worth, I don't think this is possible.
Reason being, the Marlin FW silently waits for a command (from a file/SD card/program) to execute. As far as I can tell there is no way for the FW to know that a print is finished, apart from the buffer going empty - but this is by no means a sure indication that the print is finished.
I am not sure how calling G28 X (as example to home your X axis) when the print is finished, is not a solution. Every slicer I know of has the feature, where the user can add gcode which will be executed once the print is finished.
I know you mention this, but I just reiterate for some silly reason :D
Perhaps someone will correct me, but I am 99% sure that the firmware, as it is currently written, can not do this (unless a great deal if changes are made to it).
Reason being, the Marlin FW silently waits for a command (from a file/SD card/program) to execute. As far as I can tell there is no way for the FW to know that a print is finished, apart from the buffer going empty - but this is by no means a sure indication that the print is finished.
I am not sure how calling G28 X (as example to home your X axis) when the print is finished, is not a solution. Every slicer I know of has the feature, where the user can add gcode which will be executed once the print is finished.
I know you mention this, but I just reiterate for some silly reason :D
Perhaps someone will correct me, but I am 99% sure that the firmware, as it is currently written, can not do this (unless a great deal if changes are made to it).