Fix crash on program termination.