No need for all that complicated scripting! Let native non-script KM actions do the work for you:
Here's the macro to close ALL tabs to the left.
I'm sure you can mod to close only 1.
MACRO: Close All Tabs to Left of Current Tab
**Requires: KM 8.2.4+ macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))
#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/8/d/8d525cc010b20d7de1e9489aeef8627f8b1d895e.kmmacros">Close All Tabs to Left of Current Tab.kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
<img src="/uploads/default/original/3X/2/2/22e87ed489ffd82110ad2ee4c204ee9074ccc20f.png" width="650" height="724">