Thanks for your bug report. I have not been able to reproduce this so far. I created a custom dialog, added an sclick event, and used your set statement in it. If I click cancel in the $sdir() dialog, it just closes the $sdir() dialog for me.

Can you create a minimal custom dialog script that reproduces this issue for you?