ensure clean termination