Improve REST API multithreading. Now respects CogServer 'shutdown' command