Yes, of course.
Question: Does it have to be exactly 5 minutes or can it be up to about 6 minutes?
An event handler receives the values and when power is 0 for the first time, it saves the timestamp.
If power > 0, the timestamp is deleted.
If 5 minutes later (current timestamp - saved timestamp) the power is still 0, the output is turned off.
This is the simple algorithm.