Fixes #1013

The fix @ajoslin provided doesn't work. All what's being extended in his fix is later overloaded 20 lines below (scope.destructiveButtonClicked, scope.buttonClicked and scope.cancel). Furthermore, the error doesn't come from calling scope.cancel() but from calling opts.cancel(). I've eliminated the redundant code and also fixed the original bug.