title: How to close all terminals with a bash script that effectively presses Cntrl+Shift+Q in each terminal
body: <p>I often have many terminals open, some of which are running important processes (e.g. servers) and others which are not running anything and can be closed. The 'important' ones bring up prompts for confirmation if you press <code>Cntrl</code>+<code>Shift</code>+<code>Q</code> in them, like the one shown below.</p>
  
  <p><a href="https://i.stack.imgur.com/Nmt9N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nmt9N.png" alt="enter image description here"></a></p>
  
  <p>I would like to have a (bash) script which closes all terminals but leaves the 'important' ones in the mode shown above. From <a href="https://askubuntu.com/questions/608914/closing-all-instances-of-terminal-at-once-cleanly">https://askubuntu.com/questions/608914/closing-all-instances-of-terminal-at-once-cleanly</a>, I obtained the following script:</p>
  
  <pre><code>#!/bin/bash
  
  xdotool search --class "terminal" | while read id
  do
        xdotool windowactivate "$id" &amp;&gt;/dev/null
        xdotool key ctrl+shift+q
        sleep 0.2
  done 
  </code></pre>
  
  <p>However, I found after running the script that some 'unimportant' terminals still remained open. Is there perhaps a bug in the script above?</p>