Saving data when app is closed

Hello,

So briefly is there anyone who could help me with this problem: I want to save Step count to a graph at the end of the day at 23:59 how could I do it, when the app is closed? Yes I know I can take the history of the steps(plugin), but… I have other values too that needs to be saved… like date etc