I find it hard to think of tabs in the singular. I don't have the tab bar display when there is only one tab. Here is some code that seems to work for catching the close on each tab. Hope it helps.
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- OCT_test.kmm
# --------------------------------------------------------------------------------
_OCT_test_close_tab{
alert("Closed tab - tabs remaining " . $TabNumber-1, "Action is close a tab", INFO);
}
_OCT_test_close_last_tab{
$kTabs?alert("Closed tab - tabs remaining " . $TabNumber-1, "Action is close the last tab", INFO):0;
}
_OCT_test_tab_count{
alert( $TabNumber, "Current tab count", INFO);
}
_OCT_test_BuildMenu{
$kTabs?setmenu("&File",macro,"OCT test",_OCT_test_tab_count,-1):0;
}
$OnInit=$OnInit."_OCT_test_BuildMenu;";
$OnCloseTab=$OnCloseTab."_OCT_test_close_tab;";
$OnCloseWindow=$OnCloseWindow."_OCT_test_close_last_tab;";
$macroModules=$macroModules."OCT_test;";