The flow of the problem is:
- When the printer will end, the Marlin will reads the "M81" command
- The PS_ON pin rises
- Now the relay will open the circuit and the printer power off
- So the ramps will power off, and the PS_ON pin will fall
- The relay will close
- And in the end the printer will power on, again....
So we need something with a memory, that can remember the last state of the PS_ON pin.