Ensures a dialog is instantiated before calling 'close'. Fixes #366
Merge pull request #367 from qcubed/bugfix-366

Ensures a dialog is instantiated before calling 'close'. Fixes #366