Move appstate restoration into init function.
Implemented "quit" hook for action.cleanup_tmp_files,
fixed app_restore `w.set_current_page` bug.