Fixed memory leaks caused by don't called destructors in case of exit(0) usage.