Fixed a bug that caused the application to crash if the main activity was destroyed whilst a dialog box was active