Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content

close method

Closes the current browser window or HTML Application (HTA).

Closes the app without prompting the user. To the user, it appears as though the app has crashed.


HRESULT retVal = object.close();


This method has no parameters.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

There are no standards that apply here.


How a window is closed programmatically determines whether the user is prompted with a confirmation dialog box:

  • Invoking the IHTMLDialog::close method on a window not opened with script displays a confirmation dialog box. Using script to close the last running instance of Windows Internet Explorer also opens the confirmation dialog box.
  • Invoking the IHTMLDialog::close method on an HTA closes the application without prompting the user because the HTA is trusted and follows a different security model. For more information on the security model of HTAs, please refer to The Power of Trust: HTAs and Security.

Using the close method in a Windows Store app using JavaScript

Invoking the IHTMLDialog::close method on a Windows Store app using JavaScript closes the app without prompting the user.

It is against Windows Store policy to programmatically close your app. The only time an app should programmatically close is when there is an unrecoverable error, in which case the app should throw an unhandled exception or use the MSApp.terminateApp method.

In you use IHTMLDialog::close, it appears as a crash to the user is logged as a crash in the developer’s telemetry data on the Windows Store dashboard.



Community Additions

© 2015 Microsoft