       console.error "Error serializing package '#{@name}'", e.stack
 
   deactivate: ->
+    @unsubscribeFromActivationEvents()
     syntax.removeGrammar(grammar) for grammar in @grammars
     syntax.removeProperties(path) for [path] in @scopedProperties
     keymap.remove(path) for [path] in @keymaps

  mainModulePath: null
  resolvedMainModulePath: false
  mainModule: null
  deferActivation: false

  load: ->
    try

      @loadStylesheets()
      @loadGrammars()
      @loadScopedProperties()
      if @metadata.activationEvents?
        @registerDeferredDeserializers()
      else
        @requireMainModule()
