Close active windows from the Terminal I usually have multiple windows requiring to close before sleeping.
(all the contents are saved already)

I attempt to accomplish it in terminal so I can encapsulate commands to some script.

I tried:

$ close -a atom
-bash: close: command not found
$ close -a Opera
-bash: close: command not found


How to solve the problem?
Use osascript to call an AppleScript from the command line.

Save the following script or one like it somewhere, then run osacript [path to file]:

tell application "Numbers"
    activate
    close every document without saving
end tell