Remain on page for script execution


I’m making a logging tool but logging is saved on server. What I need is phantomjs to load a page and “stay” on it for a certain time. I need to log the user activity for the time he stayed. Currently I’m using
page.onLoadFinished and a settimout function to wait. console.log('Status: ' + status); shows nothing nothing (in phantomjs) but the script are not running (I have ajax and some web workers). At one point the status was printed and there was a connection with the server but for some reason the script wasn’t running. The javascript and ajax wasn’t sending anything to the server. While staying in browser (chrome, firefox) page works fine.