I believe the related man page is, XKillClient. You can use
xdotool to simulate the close button being clicked from a terminal like so.
Assuming I have a
gnome-terminal open and it's name is "saml@grinchy:/home".
Get the window ID
$ xdotool search --name "saml@grinchy:/home"
Send it a Alt+F4
$ xdotool windowactivate --sync 96488188 key --clearmodifiers \
--delay 100 alt+F4
You can put them together by embedding the first command into the second:
$ xdotool windowactivate --sync $( ...1st command...) key --clearmodifiers \
--delay 100 alt+F4
You can save yourself by letting
xdotool do both at the same time:
$ xdotool search --name "saml@grinchy:~" key alt+f4
You can adapt what I've provided to run it on windows that have the same name:
$ xdotool search --name "saml@grinchy:~"
Or on windows by other attributes. You can use
xwininfo to find out more about a particular window. Run it and then just click on the window of interest:
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0x5c04d4b "saml@grinchy:~"
Absolute upper-left X: 14
Absolute upper-left Y: 74
Relative upper-left X: 14
Relative upper-left Y: 74
Visual Class: TrueColor
Border width: 0
Colormap: 0x5c00003 (not installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +14+74 -485+74 -485-465 +14-465
Other useful tools when dealing with X11 windows are
xdpyinfo can be used to find out information about the X server. So you can figure out which window has focus:
$ xdpyinfo |grep focus
focus: window 0x5c00005, revert to Parent
xwininfo can take a
-id switch so you can provide them the Window ID that you're interested in instead of having to click on it:
$ xprop -id 0x5c00001|grep -i class
WM_CLASS(STRING) = "gnome-terminal", "Gnome-terminal"