Add workaround to fix segmentation fault on exit.