This is a naive but reliable way to unsubscribe from subscriptions in Angular. It should always work, but it isn't always necessary.
import { Subscription } from 'rxjs';
implements OnDestroy
to your class and add the necessary importprivate subscriptions: Subscription[] = [];
this.subscriptions.push(
ngOnDestroy(): void { this.subscriptions.forEach(x => x.unsubscribe()); }