[robustness] added some try catchs to apiserver/client code;
[apiclient] sending "shutdown" packet on shutdown;