Fixed JavaScript error when quitting the application