Fix an error when exiting