Using on closed windows returns error

When i use on an open window, for example:'main', console.log);

The window opens normally and i get:

{status: "success", window_id: "Window_Extension_pbmdpdeeweffwghrh_main"}

But when i close the window and call again to I get an error:

{status: "error", error: "no window with the given id was found."}


for windows with no instances (windows that not instantiated yet) you should use function.