Hi,
It should definitely be removed; in fact, I can't imagine how it's not removed, because the first line of code sends the "accept trade" command, and the next line hides the window.
Could it be that Cay was trading you again in the very time frame between you clicking "Accept" and the server receiving your command? Did you try hitting "accept" (which would send another command to the server, which should realize that you sent it an extra command)?