exit properly when running as child process
add API for direct2