Working CLI Freeze when I click the "X" (close) button

As the title said, when running a CLI executable, pressing “X” will freeze my cli program, it still can be closed by spamming the X button or using cmd taskkill. But it is still kinda annoying. Hope someone can help me. Thank you for reading

It can take some time when you exit the process in order to close all running components. Are you using some loop in your code?

when I waiting for STDIN , or downloading files with file_get_contents();

Do you have a basic PHP code to reproduce the problem?

It freezes here when I’m waiting for input. If I press the “X” button without entering the required STDIN, the CLI freezes

fputs(STDOUT, "Choose Variable"); $variable = trim(fgets(STDIN, 256));

and here when I’m downloading files:

for ($i = 0 ;$i <= $limit; $i++) { $data = file_get_contents($link); file_put_contents($filepath, $data); echo "Downloaded: $link"; }
The Download code above works fine, the files are downloaded with no error. But If I press “X” when the script is running (it is download files, but hasn’t downloaded all), the CLI freezes

Sorry for my bad English

Thank you for the code! We’ll investigate.