Unintended image closing

I have this macro designed to only make a rectangle:

macro 'makeRectangle [n2]' {
makeRectangle(1504, 3112, 1000, 2600);
{

When I run the shortcut, the image will close and I’ll get a notification saying “There are no images open.” What can I do to fix this?

Did you try running this from the script editor? (File > New > Script)
Copy paste the Marco in the editor, select Language > IJ1 Macro.
For me this works.