adding onRemove() function for resource cleanup on widgets