Fixed restoring focus when a dialog closes.

closes #2279