       lc.setShapesInProgress(@_getShapes(lc))
       lc.repaintLayer('main')
 
+    polygonFinishOpen = () =>
+      @maybePoint = {x: Infinity, y: Infinity}
+      @_close(lc)
+
+    polygonFinishClosed = () =>
+      @maybePoint = @points[0]
+      @_close(lc)
+
+    polygonCancel = () =>
+      @_cancel(lc)
+
     unsubscribeFuncs.push lc.on 'drawingChange', => @_cancel(lc)
     unsubscribeFuncs.push lc.on 'lc-pointerdown', onDown
     unsubscribeFuncs.push lc.on 'lc-pointerdrag', onMove
     unsubscribeFuncs.push lc.on 'lc-pointermove', onMove
     unsubscribeFuncs.push lc.on 'lc-pointerup', onUp
+
+    unsubscribeFuncs.push lc.on 'lc-polygon-finishopen', polygonFinishOpen
+    unsubscribeFuncs.push lc.on 'lc-polygon-finishclosed', polygonFinishClosed
+    unsubscribeFuncs.push lc.on 'lc-polygon-cancel', polygonCancel
 
   willBecomeInactive: (lc) ->
     @_cancel(lc) if @points or @maybePoint

    else
      null

  _ensureFinishButtonsExist: (lc) ->
    return if @containerEl
    html = "
      <div
        class='square-toolbar-button horz-toolbar'
        id='polygon-finish-closed'>
        <img
          alt='Finish polygon (closed)'
          title='Finish polygon (closed)'
          src='#{lc.opts.imageURLPrefix}/polygon-closed.png'>
      </div>
      <div
        class='square-toolbar-button horz-toolbar'
        id='polygon-finish-open'>
        <img
          alt='Finish polygon (open)'
          title='Finish polygon (open)'
          src='#{lc.opts.imageURLPrefix}/polygon-open.png'>
      </div>
      <div
        class='square-toolbar-button horz-toolbar'
        id='polygon-cancel'>
        <img
          alt='Cancel polygon'
          title='Cancel polygon'
          src='#{lc.opts.imageURLPrefix}/polygon-cancel.png'>
      </div>
    "
    @containerEl = document.createElement('div')
    @containerEl.className = "polygon-toolbar horz-toolbar"
    @containerEl.innerHTML = html
    lc.containerEl.appendChild(@containerEl)

    document.getElementById('polygon-finish-closed')
      .addEventListener 'click', (e) =>
        @maybePoint = @points[0]
        @_close(lc)

    document.getElementById('polygon-finish-open')
      .addEventListener 'click', (e) =>
        @maybePoint = {x: Infinity, y: Infinity}
        @_close(lc)

    document.getElementById('polygon-cancel')
      .addEventListener 'click', (e) =>
        @_cancel(lc)

  _ensureFinishButtonsDontExist: (lc) ->
    return unless @containerEl
    lc.containerEl.removeChild(@containerEl)
    @containerEl = null

    onUp = =>
      return @_close(lc) if @_getWillFinish()
      lc.trigger 'lc-polygon-started'

      if @points
        @points.push(@maybePoint)
