diff --git a/index.coffee b/index.coffee
index 71b56a42177876f348306116cff6cbb69aeb27d1..ffd4f52a9732bb0a9bedbab1ad7975c443d3442f 100644
--- a/index.coffee
+++ b/index.coffee
@@ -40,7 +40,11 @@ module.exports =
 				projects[path] = (parseInt pid) + 1
 				writeFile tmp, JSON.stringify projects
 
+			window.addEventListener 'beforeunload', ->
+				exec "kill #{projects[path]}"
+
 #-------------------------------------------------------------------------------
 	deactivate: ->
 		@subs.dispose()
+		window.removeEventListener 'beforeunload'
 		unlink tmp