title: ngDestroy executed too late: unable to call specif dispose method
body: <p>I guys,
  I'm having a problem using ngDestroy.  I need to call a &quot;stop&quot; method on a object initialized during ngInit, but when ngDestroy is called this object is already null.  If I don't call that stop method, a background process won't be stopped and after some time I start to receive errors.</p>
  <p>How can I do it?</p>
  <hr />
  <p>This is how I'm writing my component</p>
  <pre><code>@Component({ templateUrl: 'sample.component.html' })
  export class SampleComponent implements OnInit, OnDestroy {
  
    constructor() {  }
  
    myObject : MyObject = null;
  
    ngOnInit() {
      this.myObject = new MyObject();
      this.myObject.Start();
    }
  
    ngOnDestroy() {
      this.myObject.Stop();   //&lt;== when ngOnDestroy is executed myObject is &quot;undefined&quot;
      this.myObject = null;
    }
  }
  </code></pre>
  <p>When ngOnDestroy is called, myObject is already undefinied so I cannot call Stop method.  If that method is not called, the background process started during ngOnInit will work forever.</p>
  <p>How can I solve it?</p>