Console.log isn't being working

I am using log2js to log errors. Currently i am using the following code to trap nodejs exiting:

process.on('SIGINT', function (code) {
	process.exit(0);
});

process.on('SIGTERM', function (code) {
	process.exit(0);
});

process.on('exit', function (code) {
	log4js.shutdown(function () {
		console.log('All logs flushed');
	});
  console.log(`About to exit with code: ${code}`);
});

However only the last console.log is displayed. The one inside log4js.shutdown never fires. Here is the code i am using. I am expecting it to show in my terminal window in my codeanywhere instance like the last one does. If someone could help me it would be greatly appreciated.