     else if options.forceMinimize
       current.on 'close', (e) ->
         current.minimize()
-        e.preventDefault() unless forceClose
+        e.preventDefault() unless forceClose || pluginUnload
+      current.on 'closed', (e) ->
+        if pluginUnload then pluginUnload = false
+        if options.indexName?
+          delete windowsIndex[options.indexName]
+        idx = _.indexOf windows, current
+        windows.splice idx, 1
     else
       current.on 'close', (e) ->
         if current.isFullScreen()

          current.setFullScreen(false)
        else
          current.hide()
        e.preventDefault() unless forceClose
    # Draggable
    unless options.navigatable
      current.webContents.on 'will-navigate', (e) ->

forceClose = false
state = []  # Window state before hide
hidden = false
pluginUnload = false

module.exports =
  createWindow: (options) ->
