Why?
Back up to your original requirements:
“Light should switch OFF five minutes after last motion”
OK, so we have a motion sensor Item that changes when motion is detected. Does this Item change back to OFF automatically, in less than five minutes, in more than five minutes, or never?
If the Item is already ON, what happens if new motion is detected? Nothing or does the Item get updated to ON?
The answer to these are important because that changes how the rule should be triggered, whether by changed to ON or by update to ON.
How does the light turn ON? Should that happen in this rule?
If we assume that the Item gets updated to ON on every motion detection, the rule gets triggered by “updated to ON” and in the rule test to see if a timer already exists. If it does, reschedule it for five minutes from now. If not, create a new timer to command the light to OFF five minutes from now.
Five minutes after the last motion is detected, the timer will go off and command the light to OFF.
No loop required as shown in the replies here.
See Design Pattern: Motion Sensor Timer for a detailed discussion with examples.
But the key is understanding when and how your motion sensor Item works. You want to trigger the rule every time motion is detected.
It is probably overkill for this but Threshold Alert and Open Reminder [4.0.0.0;4.9.9.9] can be configured to handle this use case, no coding required. But the correct configuration of this too depends on the behavior of the motion sensor Item.