Fix a small bug on exit