---
version: "2026.1.0"
language: "en"
---
# Close UI Window

The **Close UI Window** block is used to close a desktop application window as part of a desktop UI automation flow. If no window input is provided, the block closes the last active window; if a window handle is supplied, it closes that specific window instead.

Fully expanded, the **Close UI Window** block shows the following properties:  
![image-20260119-121610.png](https://docs.leapwork.com/__attachments/a_1c24c5751a5586fc2f59c122e7b26a385b053bcf4fbdba61a73400a2a57895c7/image-20260119-121610.png?cb=ec1f5c1b5c3eaa35050bd42dba039ced)

**Note:** The screenshot on this page uses the **Elegance Design** , introduced in **2025.3**. If you are using an earlier version, your layout may look different.

## Quick-start

1. Drag **Close UI Window** onto the canvas.

2. Connect it in the flow and set the basic parameters you need, such as **Close method** , **Close timeout** , **Default timeout** , and (optionally) **Window**.

3. Run the flow when it's ready; the block will attempt to close the chosen window and branch on **Close timeout** if the window does not close in time.

## Building block parameters

Parameters  
* **Block header:** Shows the current name of the **Close UI Window** block. You can rename it by double-clicking the header and typing a new title. The green input connector starts the close operation when the flow reaches this block, and the green output connector triggers when the UI window has been closed successfully.

* **Close method:**Defines how the window should be closed:

  * **Send Win message** (default): sends a standard Windows close message to the application under test.

  * **Force kill process** : forcibly terminates the process if a normal close is not sufficient or the application is unresponsive.

* **Close timeout:** Green output connector that is triggered if the window is not closed within the configured timeout period. Use this connector to handle alternate flows, such as logging, retries, or forced termination.

* **Default timeout:**Controls how the timeout is determined:

  * When the checkbox is **not selected** , the block uses an explicit **Timeout** value of **10 seconds**, unless you change it.

  * When the checkbox is **selected** , the block uses the **Default timeout** value defined in the flow settings.

* **Timeout:** Specifies the maximum time the block will wait for the UI window to close before giving up and triggering **Close timeout** .

  This timeout is specific to the block. Each case also has a separate **global timeout** configured in the **Settings** panel; if the case runs longer than that global timeout, it is automatically cancelled regardless of this block's timeout.

* **Window:**Holds the handle of the window to be closed.

  * Typically, this is provided by a **Start Application** or **Use Window** block.

  * If this input is left empty, **Close UI Window** will attempt to close the last active window instead.

## Resources

|                                                **Topic**                                                |                                                                                       **Description**                                                                                        |
|---------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Flows FAQ](https://docs.leapwork.com/faq/latest/leapwork-flow-faq/flows-faq.md)                                                 | Common questions about creating, running, and managing flows in Leapwork.                                                                                                                    |
| [Flows Troubleshooting](https://docs.leapwork.com/troubleshooting/latest/leapwork-flow-troubleshooting/flows-troubleshooting.md) | Guidelines and solutions for identifying and fixing issues that occur when building or running flows in Leapwork.                                                                            |
| [Strategy Editor](https://docs.leapwork.com/leapwork-flow/latest/working-with-leapwork/strategy-editor.md)                       | Guidelines for understanding and using the Strategy Editor in Leapwork to define, refine, and validate robust locator strategies for UI elements using DOM structure, tokens, and wildcards. |