Window doesn't close when it's dragged WHILE CLI app exits #17298

Closed
opened 2026-01-31 05:38:12 +00:00 by claunia · 9 comments
Owner

Originally created by @BlockyTheDev on GitHub (Apr 20, 2022).

Windows Terminal version

1.12.10733.0

Windows build number

10.0.22000.613

Other Software

No response

Steps to reproduce

  1. Create batch-file with timeout /t 5
  2. Doubleclick batch file
  3. While timer is going down move the window until the timer ends with the mouse (It is not important, when you start moving the windows, it is important that you have it ON your mouse with a pressed key, when the timer ends)
  4. Try to close the windows with pressing a key or pressing the X-Button in the right upper corner to close it

Expected Behavior

The window should close automatically after releasing the mouse (Or with pressing a key or the X-Button)

Actual Behavior

The window is NOT closing automatically, with pressing a key or with the X-Button.
image

https://user-images.githubusercontent.com/86119630/164326069-bd55d556-6c07-4f75-af06-e90b9ce69939.mp4

Originally created by @BlockyTheDev on GitHub (Apr 20, 2022). ### Windows Terminal version 1.12.10733.0 ### Windows build number 10.0.22000.613 ### Other Software _No response_ ### Steps to reproduce 1. Create batch-file with `timeout /t 5` 2. Doubleclick batch file 3. While timer is going down move the window until the timer ends with the mouse (It is not important, when you start moving the windows, it is important that you have it ON your mouse with a pressed key, when the timer ends) 4. Try to close the windows with pressing a key or pressing the `X`-Button in the right upper corner to close it ### Expected Behavior The window should close automatically after releasing the mouse (Or with pressing a key or the `X`-Button) ### Actual Behavior The window is NOT closing automatically, with pressing a key or with the `X`-Button. <img width="866" alt="image" src="https://user-images.githubusercontent.com/86119630/164322409-df315851-e36c-4916-89c3-56126e01b3e9.png"> https://user-images.githubusercontent.com/86119630/164326069-bd55d556-6c07-4f75-af06-e90b9ce69939.mp4
claunia added the Help WantedIssue-BugNeeds-Tag-FixProduct-TerminalPriority-1 labels 2026-01-31 05:38:13 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Apr 21, 2022):

That's wild. Thanks for the great bug report! I wonder why moving the window while the last tab closes prevents the app from tearing down....

@zadjii-msft commented on GitHub (Apr 21, 2022): That's wild. Thanks for the great bug report! I wonder why moving the window while the last tab closes prevents the app from tearing down....
Author
Owner

@hez2010 commented on GitHub (Apr 26, 2022):

To work around, add a new tab and then you can close the window.

@hez2010 commented on GitHub (Apr 26, 2022): To work around, add a new tab and then you can close the window.
Author
Owner

@BlockyTheDev commented on GitHub (Apr 26, 2022):

To work around, add a new tab and then you can close the window.

Yes I found this work around too.

@BlockyTheDev commented on GitHub (Apr 26, 2022): > To work around, add a new tab and then you can close the window. Yes I found this work around too.
Author
Owner

@zadjii-msft commented on GitHub (Dec 5, 2022):

Oh god this is so much worse in 1.15. It doesn't timeout at all, it instantly exits!

echo foo
@rem set /p id=Enter ID: 
timeout /t 10
echo bar
exit 1234

image

@zadjii-msft commented on GitHub (Dec 5, 2022): Oh god this is so much worse in 1.15. It doesn't timeout at all, it instantly exits! ```cmd echo foo @rem set /p id=Enter ID: timeout /t 10 echo bar exit 1234 ``` ![image](https://user-images.githubusercontent.com/18356694/205757385-aa1719f2-cffd-41ee-8d9b-a8ec19051610.png)
Author
Owner

@zadjii-msft commented on GitHub (Dec 6, 2022):

OH oh oh I bet this has to do with focus events. That's my guess - timeout will bail on input. Like, any input? That I'm not sure about. But I bet the regression between 1.12 when this was filed, and now (1.15/16/17) is the focus event stuff, and I bet eveything is immediately getting a focus event in the input queue right off the bat.

I'll need to go inspect timeout's source to confirm. That's my hypothesis.

Notably, this doesn't repro the same if you actually "restart" the batch script, until you press a key:
image

I noticed this when I restored the Terminal from being quit, and this defterm window came back (presumably, without the focus event). This might be related to #13514

Okay, my hypothesis was wrong. Looks like timeout does filter FOCUS events out... even if it does have some other horrifying code in it.

@zadjii-msft commented on GitHub (Dec 6, 2022): ~OH oh oh I bet this has to do with focus events. That's my guess - `timeout` will bail on input. Like, any input? That I'm not sure about. But I bet the regression between 1.12 when this was filed, and now (1.15/16/17) is the focus event stuff, and I bet eveything is immediately getting a focus event in the input queue right off the bat.~ I'll need to go inspect `timeout`'s source to confirm. That's my hypothesis. Notably, this doesn't repro the same if you actually "restart" the batch script, until you press a key: ![image](https://user-images.githubusercontent.com/18356694/205942092-7f79e221-790c-47cc-8ee5-9df8cf558c8a.png) I noticed this when I restored the Terminal from being quit, and this defterm window came back ~(presumably, without the focus event)~. This might be related to #13514 Okay, my hypothesis was wrong. Looks like `timeout` does filter FOCUS events out... even if it does have some other horrifying code in it.
Author
Owner

@hez2010 commented on GitHub (Dec 6, 2022):

I also reproduced it a few days ago by accident.

@hez2010 commented on GitHub (Dec 6, 2022): I also reproduced it a few days ago by accident.
Author
Owner

@zadjii-msft commented on GitHub (Dec 6, 2022):

I'm gonna fork my above comments into a separate bug, cause there's multiple bits here with different tiers of badness.

@zadjii-msft commented on GitHub (Dec 6, 2022): I'm gonna fork my above comments into a separate bug, cause there's multiple bits here with different tiers of badness.
Author
Owner

@zadjii-msft commented on GitHub (Mar 16, 2023):

Actually, this doesn't have anything to do with defterm at all. This repros pretty readily with sleep 3 ; exit 0 in powershell too.

@zadjii-msft commented on GitHub (Mar 16, 2023): Actually, this doesn't have anything to do with defterm at all. This repros pretty readily with `sleep 3 ; exit 0` in powershell too.
Author
Owner

@lhecker commented on GitHub (Jul 9, 2025):

Fixed in Windows Terminal Preview 1.23 via #18215.

@lhecker commented on GitHub (Jul 9, 2025): Fixed in Windows Terminal Preview 1.23 via #18215.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17298