Fix window layout issue

When invoking platform code (e.g. Dialog.Run), make sure the exit actions
are always executed.