test: Fix restart node race
Summary:
It is not allowed to start a node before it has been fully stopped. Otherwise it could lead to intermittent issues due to access issues (e.g. cookie file https://cirrus-ci.com/task/6409665024098304?command=ci#L4793) Fix that by waiting for the node to fully stop.
I have also seen this issue on CI a few times.
Backport of core PR20683.
Test Plan:
ninja check-functional
Reviewers: #bitcoin_abc, majcosta
Reviewed By: #bitcoin_abc, majcosta
Differential Revision: https://reviews.bitcoinabc.org/D8881