TCP doesn't have any concept of the remote server "crashing". When a program with an open TCP socket ends (regardless of how), the OS will close the socket.
In order to do what you want, you would need to create a protocol where the server would acknowledge completion of whatever operation you want it to perform and then the client would exit with failure unless it got that application-layer acknowledgement.