This assignment is wrong. You're assigning the entire inline widget as close button. What you want is create an element with your "a" tag and assign it to the close button before append it to $htmlContent. 

Now with this code you can close the inline editor just clicking anywhere inside the inline.