How to close nodewebkit app though server side nodejs code

I am running webkit from a nodejs script with child_process.exec process

-> server.js

var child = require('child_process').exec('nodewebkit', function(err){
        if(err) throw err;
      });

The code is inside the directory where nodewebkit 'package.json' and 'index.html' is kept, for running nodewebkit app.

So that when i run

node server.js

the nodewebkit app should get automatically start.

Now upon some event, i want to close the current nodewebkit app through the same script.

How to do that??

EDIT :

I have tried the following :

child.kill(); //not working, does not close the app

require('child_process').exec('kill '+child.pid, function(err){}); //doesn't close the app