Function runs every 5min and sometime it will close before create snapshot. add logic to ensure the function will create snapshot before exiting