_hook: use promises to detect end of process (introducing promises in API, may switch entirely)