componentWillUnmount is called just before a component is removed from the DOM, used for cleanup tasks like removing event listeners.