SR04 ultranosic sensor

Hi guys, I'm designing a project where I am using a HC-SR04 ultrasonic sensor to measure the distance of a liquid. I want to know how to apply the logic, that when the distance of my signal is not read for more than 5 seconds the arduino will power off. Is this possible?

Project.ino (1.15 KB)

Something along these lines maybe:-

Hold the pushbutton until the Arduino starts up, the sketch immediately makes "pwrPin" high to maintain power, then writes that pin low when the power has to be cut.
It would work well with a 12V supply/12V relay, or 9V supply/6Vrelay if a small Zener or resistor was added in series with the relay coil.