   @content: ->
     @div class: 'spell-check'
 
-  @task: null
-  @instances: 0
+  @createTask: ->
+    @task ?= new Task(require.resolve('./spell-check-handler'))
+    if @activeViews?
+      @activeViews++
+    else
+      @activeViews = 1
 
-  views: []
+  @destroyTask: ->
+    @activeViews--
+    if @activeViews is 0
+      @task?.terminate()
+      @task = null
 
   initialize: (@editorView) ->
-    @constructor.task ?= new Task(require.resolve('./spell-check-handler'))
-    @constructor.instances++
+    @views = []
+    @constructor.createTask()
 
     @subscribe editorView, 'editor:path-changed', @subscribeToBuffer
     @subscribe editorView, 'editor:grammar-changed', @subscribeToBuffer


  spellCheckCurrentGrammar: ->
    grammar = @editorView.getEditor().getGrammar().scopeName
    _.contains atom.config.get('spell-check.grammars'), grammar

  destroyViews: ->
    while view = @views.shift()


  beforeRemove: ->
    @unsubscribeFromBuffer()
    @constructor.destroyTask()

  unsubscribeFromBuffer: ->
    @destroyViews()
