Update: I have found some related info about the javascript functions used in the above code. A possible bug was mentioned involving usage of getTime(), something about large numbers might crash browsers, anyway it was not clear.
But after changing the above function to getSeconds(), it looks like my full screen Kindle browser does not exit any more