Thank you.
It works for closing, but not for the jpeg image quality option.
When running the script it does close the files without asking to confirm the save, but after that it asks me the options for the jpeg quality value.
Basically I still have to give that value, and click the "ok" button.
When I crop, and resize the image, and close the file it first asks me if I want to save the changes (step 1), when I say save it prompt me to set the image quality option, and then click ok (step 2).
The script you kindly provided takes care of the step 1.