lose hotspot data after shut down

I have mikrotik router OS v4.5 with hotspot account. I have daily schedule shutdown but I notice that if there are active users, thier latest download(byte-out) is not added to thier profiles.
Is there a code to add to the scheduler to remove all active users before shut down and how much delay is needed between the two commands.


Note:
-2 min after the automatic shutdown the power is cut automaticaly from the Mikrotik system ( I have power timer attach to the power plug) and turn on after one hour.
-Do I need to increase the time between Mikrotik shutdown and power plug shut down?

This script will remove (edit: log out) users:

:local dumplist [/ip hotspot active find]
:foreach i in=$dumplist do={
    /ip hotspot active remove $i
}

It removes (edit: logs out) the users, but I haven’t tested this to see if the last transfers are added to the user totals. If you try it, let me know.

EDIT: This does not remove the user from the “/ip hotspot user” database. Just logs out.

thank you, the script is working.

the script is working when I do run script. but when I schedule the script to run at specific time, it doesn’t work

I haven’t run it scheduled before. I use it to log out users so I can work on the router. I just tried the script with the scheduler, and it does not work here either. I saw nothing about the “remove” parameter being CLI shell only. I know the “:put” command only works in a shell. Maybe someone else will come up with the reason.

does this work?

/ip hotspot active remove [/ip hotspot active find]

In the schedule in Winbox, I put tick on all the policies and it is working now.