Fix closing stacked dialogs

If two dialogs were stacked, when the top one closed we assumed the
top widget would have a title, but it may be another dialog in which
case it does not.

Change-Id: I9353400bf6000bfd106783c157412df150c76d1e