   # Remove hash from url to ensure IE 10 compatibility
   safeUrl = removeHash url
 
+  xhr.abort() if xhr
   xhr = new XMLHttpRequest
   xhr.open 'GET', safeUrl, true
   xhr.setRequestHeader 'Accept', 'text/html, application/xhtml+xml, application/xml'
   xhr.setRequestHeader 'X-XHR-Referer', referer
-
+  xhr.onabort = ->
+    xhr = null
   xhr.onload = =>
     doc = createDocument xhr.responseText
 

loadedAssets   = null
pageCache      = {}
createDocument = null

visit = (url) ->
  if browserSupportsPushState

      else
        resetScrollPosition()
      triggerEvent 'page:load'
    xhr = null

  xhr.onerror = ->
    document.location.href = url
    xhr = null

  xhr.send()

