     marker = editor.markBufferRange(range)
 
   toggleDebugging: ->
-    if not @window
+    pane = atom.workspace.paneForItem(@unifiedWindow)
+    if !pane
       @showWindows()
-      @dbgp.listen()
+      if !@dbgp.listening()
+        @dbgp.listen()
     else
-      console.dir @window
+      pane.destroy()
+      delete @unifiedWindow
+      @dbgp.close()
 
   run: ->
     if @GlobalContext.getCurrentDebugContext()

        when PhpDebugWatchUri
          createWatchView(uri: PhpDebugWatchUri)
        when PhpDebugUnifiedUri
          @window = @createUnifiedView(uri: PhpDebugUnifiedUri, context: @GlobalContext)
    Dbgp = require './engines/dbgp/dbgp'
    @dbgp = new Dbgp(context: @GlobalContext, serverPort: atom.config.get('php-debug.ServerPort'))
    @GlobalContext.onBreak (breakpoint) =>

    editor = atom.workspace.getActivePane()
    editor.splitDown()
    atom.workspace.open(PhpDebugUnifiedUri)
      .then (unifiedWindow) =>
        @unifiedWindow = unifiedWindow

  toggleBreakpoint: ->
    editor = atom.workspace.getActivePaneItem()
