This is indeed part of a safe shutdown circuit.
This pin needs to be HIGH while the raspberry pi is on and not change its state before shutdown process completes, because it drives the mosfet that provides power to the pi.
Thank you, I will try your script although I don't understand it.