It's very easy to do so. Just add this code after the ChatWindow.SendMessage() call which you used to send the text:
code:
ChatWindow.SendMessage("/close");
This will send the Plus! command /close, which closes the window. No need for Plus! Live script functions, and it's far more easy!