Fixed log not being closed on termination.