@wenqing I think both @norihiro-w and @rinkk suggests the right way to handle this case.
> This is a class in a library and not a main program. Only main program should have a permission to start and exit its process.

I fully support this statement from Nori!