I created a script for the same exact problem, and so far it works like a charm (link at the bottom).
I run it nightly and so far never failed ![]()
Mind, I only tested it on 3.xx, so 4 and 5 are uncharted territory.
If you can test it on 5.xx and let me know, it would be great!
http://forum.mikrotik.com/t/solution-automatically-clean-expired-user-manager-accounts/47558/1