Fixes #46, only dismiss a dialog if it's showing...