 
     # Emitted when the window is about to close.
     # For OSX only hides the window if we're not force closing.
-    # Prevent close, if minimizetotray is enabled.
     mainWindow.on 'close', (ev) ->
-        hideToTray = !readyToClose and nconf.get 'minimizetotray'
         darwinHideOnly = process.platform == 'darwin' and not mainWindow?.forceClose
 
-        if hideToTray or darwinHideOnly
+        if darwinHideOnly
             ev.preventDefault()
             mainWindow.hide()


seqreq = require './seqreq'

saveConfig = ->
    nconf.save (err) ->
        console.log 'error while writing config.json', err if err

# Load configuration
nconf = require 'nconf'
nconf.file { file: paths.configpath }
nconf.defaults {
    'startminimized': false
    'minimizetotray': false
}

mainWindow = null


toggleWindowVisible = ->
    if mainWindow.isVisible() then mainWindow.hide() else mainWindow.show()

# helper wait promise
wait = (t) -> Q.Promise (rs) -> setTimeout rs, t

app.on 'ready', ->

    proxycheck = ->
        todo = [
