make error logging synchronous
wait for log being fully written prior to process exit
Merge pull request #119 from mexx/fix-error-logging

make error logging synchronous