For questions about ngondestroy, a lifecycle hook from the Angular Framework that is called when a directive, pipe, or service is destroyed.
ngOnDestroy
is a callback method that performs custom clean-up, invoked immediately after a directive, pipe, or service instance is destroyed and so, it is generally used for any custom cleanup that needs to occur when a (component, directive, or service) instance is destroyed.
See also, the documentation for the interface OnDestroy