Detecting an X click or something like Alt-F4 (close window) or even a process kill with a task manager is relatively trivial. Depending on the OS, such things generate specific signals or events.
There is no reason for the percentage function to work as badly and indiscriminately as it does.
It is possible that the OP has not seen the bad stuff. Following the game mentioned above, wherein all parties were penalized, we immediately played another game. The new player also disconnected, but NO ONE was penalized for that one.
Correcting this problem is trivial compared to the software associated with the physics engine. The marketing and customer service people need to go talk to the software boss and get someone moving on this.