You're running the exit on the remote server. The section running there exits, and so ssh ends and the remainder of whatever's local then continues.
You've not shown any part that "continues even though the test fails", either on the remote host or the local system, so we cannot test with confidence we're trying what you're trying.