       tailIndex += 2
       @holes.push new Hole(@agda, i, headIndex, tailIndex)
 
-    @agda.on 'quit', @destroyHoles
+    @agda.once 'quit', @destroyHoles
 
   # convert all '?' to '{!!}'
   expandBoundaries: ->

  holes: []

  constructor: (@agda) ->
    @destroyHoles()
    @expandBoundaries()



  destroyHoles: =>
    # first, destroy all Holes
    @holes.forEach (hole) =>
      hole.emit 'destroyed'
      @holes = []
    # second, destroy wandering markers
    markers = @agda.editor.findMarkers type: 'hole'
    markers.map (marker) => marker.destroy()
