Check subscription truthy before calling dispose()

A TypeErorr is thrown when _subscriptionsToDependencies is an empty array
because splice() will return undefined on which the old code would try to call
dispose(). So we first ensure the subscription is valid before making the call.

Fixes #1041