CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times.