Alternatively if you find this solution to become a nuisance because the light keeps turning off even though you are still moving around 5 minutes later you can set up two if statements.
You have the first already you would just need to take out the wait and turn off commands.
The second would be all the same as the first except now you want the trigger to be changes to inactive. Then you add the wait and turn off commands into that if statement.
Now when there is motion the light turns on. When there has been no motion for the wait time it turns off. But it will cancel the tasks if the motion changes back to active.
Lastly if you decide to go this route, make sure you reset the TCP so that it can cancel these tasks.