return exit status from task::main. use wait_for_tasks in spawn_thread.