refactored instance termination