diff --git a/server-client.c b/server-client.c
index 7b7a3e4a..7f5bfe13 100644
--- a/server-client.c
+++ b/server-client.c
@@ -912,8 +912,10 @@ server_client_msg_identify(
 		return;
 	}
 
-	if (!isatty(fd))
-	    return;
+	if (!isatty(fd)) {
+		close(fd);
+		return;
+	}
 	data->term[(sizeof data->term) - 1] = '\0';
 	tty_init(&c->tty, c, fd, data->term);
 	if (data->flags & IDENTIFY_UTF8)