Added termination code path

Error in each of main threads should now lead to termination of all 3 (attempting flush if possible).