Fix crash on exit introduced by #1