JS: ensure the program exits if an error occurs during batch-run operation

Signed-off-by: Harvey Harrison <harvey.harrison@ausenco.com>