The closeStackRequest message is only sent if the request to close a stack is initiated by the user (eg by clicking file -> close in the LiveCode menu). If the request is initiated from a script (eg "close this stack" ) then the closeStackRequest message is not sent.
on closeStackRequest answer "Are you sure?" with "No" or "Yes" if it is "Yes" then pass closeStackRequest pass closeStackRequest end closeStackRequest
Use the closeStackRequest Message handler to prevent a stack from being closed.
You have to pass the closeStackRequest. If the closeStackRequest handler does not pass the message or send it to a further object in the message path, the stack does not close. Passing the message allows the stack to close.