Fixes the error #14670 (comment) reported by @ken2812221.
There is a race between RPC stop and another concurrent call in the test framework. The connection must be established and the command waitfornewblock
running before calling stop
.
See also #14670 (comment).