I think the activity time is updated as a "shutdown query", and they normally get executed at the end when you call print_output(). But you're probably not calling that. I think you might be able to add a call to exec_shut_down() at the end of your code to take care of it. (You may have to include includes/functions.php).