Writes actions to a file when browser is closed