Script running in the background

I want to add a script that loads the highscore etc. from playerprefs at startup, and saves the highscore etc to the playerprefs when the application is closed. Besides that i would like other script to acces and edit these values. How should i do this?

Perhaps use something like

function OnApplicationQuit () {
// put your script here to save the file when scene closed or application closed
}