Is there any kind of lifecycle event, which fires when app is closed? So i can for example save data before closing or something like that?
Not as far as I know.
“going to be closed” is also quite vague. There are lots of ways an app can be closed on iOS and Android for example.
You should save data as soon as possible and make sure it is never in an invalid state.