Hi,
For this, you would need an external power supply like a battery. As the power disrupts immediately there is no way to activate digital output in between that time. There must be some time to shorten the input pin so it could activate the output.
So I believe this would need your own time and development as there is no functionality or possibility we could do that for you.
EB.