function closeInlineWidget(hostEditor, inlineWidget) {
        // If widget has focus, return it to the hostEditor & move the cursor to where the inline used to be
        if (inlineWidget.hasFocus()) {
            // Place cursor back on the line just above the inline (the line from which it was opened)
            // If cursor's already on that line, leave it be to preserve column position
            var widgetLine = hostEditor._codeMirror.getLineNumber(inlineWidget.info.line);
            var cursorLine = hostEditor.getCursorPos().line;
            if (cursorLine !== widgetLine) {
                hostEditor.setCursorPos({ line: widgetLine, pos: 0 });
            }

            hostEditor.focus();
        }

        return hostEditor.removeInlineWidget(inlineWidget);
    }
Removes the given widget UI from the given hostEditor (agnostic of what the widget's content
is). The widget's onClosed() callback will be run as a result.
@param {!Editor} hostEditor The editor containing the widget.
@param {!InlineWidget} inlineWidget The inline widget to close.
@return {$.Promise} A promise that's resolved when the widget is fully closed.