This has been discussed many times on the forum. You can't rely on web-based HMI to turn off the tag and the use of sleep() is an indication that your logic is bad. You shouldn't use it.
Instead,
Have the button set a bit in the PLC.
Have the PLC reset the bit when the task is done.
Have the Perspective indication tied to the PLC bit.