I have several applications open. Running wmctrl and piping the output to awk lists the window IDs (excluding "sticky" windows) like this:
$ wmctrl -l | awk ' !/-1/ { print $1 } '
0x00a00018
0x04800005
0x04e00005
0x04400003
0x05000003
0x0540002b
0x05a00012
0x05800002
0x05c00003
$ 
I can send this output to wmctrl to close all these windows:
- windows without content that needs to be saved and windows that don't need a response will be closed without asking me but 
- windows such as those of editors with unsaved content or terminals running a process will be closed "gracefully": the respective application will present a window allowing me to save changes or discard changes or to inform me of a process that's still running. 
The following script, assigned to a suitable shortcut, works:
#!/bin/bash
list=$(wmctrl -l | awk ' !/-1/ { print $1 } ')
for i in ${list[@]}
do
    wmctrl -i -a $i
    wmctrl -i -c $i
done
I found that the simpler (to me) for i in $list also works. 
Is there any reason to prefer one over the other?
"sticky" and "gracefully" are terms from man wmctrl.
 
     
     
     
     
    