Fixed a bug with log4j2. Now the program also logs when terminating.