Close All Orders (Positions)

But when does it close the positions? Let´s say I have a tp set but I want to close my positions before my tp or sl is hit how do I then use this script to close all of my positions?
 
But when does it close the positions? Let´s say I have a tp set but I want to close my positions before my tp or sl is hit how do I then use this script to close all of my positions?
It closes the positions just when you run it. It's a script - it executes only once and that's it. It doesn't stay attached to the chart.