mongosh shutdownServer throws MongoNetworkError: connection closed

I am using mongosh (version 2.3.3) to shut down a MongoDB server (version 6.0.19) programmatically in a Java application. The command being executed is:
“C:\SRDM\SRDM2.20.0.17179.257\SRDM\Svr\DBService\bin64\mongosh.exe” --port 49153 -u XXXXX -p XXXXX --authenticationDatabase admin --eval “db.getSiblingDB(‘admin’).shutdownServer();”

The shutdownServer() command successfully shuts down the database server, but a MongoNetworkError (connection closed) is thrown afterward.
Differences observed from MongoDB 5:

In MongoDB 5, using the mongo shell, I observed a different output. Here is a comparison of logs:
{“msg”:“Failed to end logical session”,“errmsg”:“socket exception”}
MongoDB 6 (with mongosh)
MongoNetworkError: connection closed