Bugfix: Close socket properly instead of aborting during test teardown
This is slower, but avoids tripping up the companion server that's polling on data and suddenly gets unexpected remote closure, triggering an exception.
Tests: ran the batch of tests 10 times, no failures