Skip to main content
Known Participant
September 22, 2025
Question

What’s the best way to deal with windows/dialogs that don’t fully close?

  • September 22, 2025
  • 1 reply
  • 213 views

I have an ExtendScript script, which creates a dialog/window, where users can insert some arguments, etc.

 

...
// This is the method that creates the window and displays it
 
window.buttons.run.onClick = function () {
window.close(1);
};

window.buttons.cancel.onClick = function () {
window.close(2);
};

window.defaultElement = window.buttons.run;
window.cancelElement = window.buttons.cancel;

var result = window.show();

return result;

}


// Then in the main function
var result = createWindow();
if (result !== 1) {
return;
}

// Do some heavy work

Occasionally, when I click to run the script, the photoshop hangs up for a while (as usual), but the window does not fully close. More specifically, I don’t see the window elements, like buttons, texts, etc., anymore, I see only the window with a blank/white background and the title. See the screenshot below.


 

This blank dialog remains open all the time until I force close photoshop. The script execution continues and even finishes, but the window remains opened.

 

I suspect that this behaviour is due to the fact that close() doesn’t actually block, so the window may not be fully closed and cleaned once it returns.

What’s the best solution to solve this problem?

$.sleep(1000) does not seem to help and it's just seems wrong to use a sleep anyway. I suppose what we need is to just execute the heavy work until the window is fully closed. 

I also tried to call app.refresh() before the heavy work, but I also don't know if this really solves the issue. 

1 reply

mglush
Community Expert
Community Expert
September 23, 2025

Hi!

What computer are you working on? Mac or Windows? What version of Photoshop? Have you checked to see that your computer is compatible with the version of Photoshop you are currently running? 

Michelle

dev102Author
Known Participant
September 23, 2025

I'm using Mac OS Sequoia (15.6.1) and Photoshop 26.9.0.

 

Here they indeed recommend Mac OS Sonoma, which is a prequel to Sequoia, but this issue has been happening to me for a long time (at least 1 year). I am quite sure I also had it with Sonoma.

dev102Author
Known Participant
September 23, 2025

And I have a MacBook Pro with Apple M3 Max with 36GB, which is a relatively powerful machine.