do proper cleanup upon exit