Add `stop` thread to terminate a running server if it finishes.

Adapted from #147 from @dinosaure