title: Why doesn't my RxJava timer application terminate?
body: <p>I have a simple application using RxJava 2: </p>
  
  <pre><code>public static void main(final String[] args) {
  
      final Scheduler scheduler = Schedulers.from(Executors.newCachedThreadPool());
  
      final Observable&lt;String&gt; ticker = Observable.interval(1L, TimeUnit.SECONDS)
          .take(10)
          .subscribeOn(scheduler)
          .map(x -&gt; x + "s");
  
      ticker.subscribe(x -&gt; {
          System.out.println(x);
      });
  }
  </code></pre>
  
  <p>It correctly prints the timer 10 times: </p>
  
  <pre><code>0s
  1s
  2s
  3s
  4s
  5s
  6s
  7s
  8s
  9s
  </code></pre>
  
  <p>However, the application does no terminate after <code>9s</code>. It seems that there is some thread keeping it alive. </p>
  
  <p>How should I implement this so that the application terminates after <code>ticker</code> completes? </p>