handle the rare case when errors occur on shoutdown process
enable sharepreference to deal with key generation
just clean up unnecessary code
add back this code just in case the server was not shoutdown during app exit process.