Cancel button should exit script and not cause infinite loop