When you press enter, the client is getting a Lua error, which is why the chat editbox stays open with your text inside. It's trying to execute your code, but there's something wrong with it.
Turn on Lua errors in Interface Options and you should see what the problem is.