make sure logs are written in the end