Await DB writes before terminating sub processes