Address issue #137 (crash due to early deletion of stream)

In stream, only release the calling thread after the last thread has exited
the last stage. This should prevent any issues related to the calling thread
being released, then deleting or otherwise damaging the stream while anything
is still active.