[Component Based] You can define a QUIT operation which is processed when a component instance is terminated. [Object Oriented] 
You can define a class destructor which is processed when a class instance is terminated.