You can not call the server.createobject on client side with onunload event.
Alternatively you can call your specific web page and from that page you can call it(c++) object within the server.
I think you want to trap the browser close button and update some statistic to the server.
following link will help you at some extent.
and also read the trick provided by Imar
hope this will help you