added config option to terminate nicely