How can you tell it isn't working?
In general, there's little time between beforeunload event, unload event and actual page exit. At page unload all running scripts are dropped (browser than closes the window or navigates to address provided by user for example).
What might be happening here is browser doesn't really have time to send ajax request before page is unloaded.
I've seen couple of ways to ensure your final request before page unload will be completed. One of them is sending request and then introducing loop that is running for X number of miliseconds, postponing unload event and ensuring ajax request can be completed.
window.onbeforeunload = function() {
fetch("http://"+window.location.hostname+"/process_sc.php?cC=" + 1);
// here we force browser to wait for 300 seconds before proceeding with unload
var t = Date.now() + 300;
while(Date.now() < t) {};
}