title: C++ app - how to stop/cleanup if it is run as Linux service?
body: <p>I have basically a console C++ app for Linux CentOS9. I am going to run it as a service using <code>systemctl start/stop</code>.</p>
  <p>Currently the app exits if user press Enter in the console but this wont be possible in service mode as the user wont see the app console after logging in.</p>
  <p>What can be done so I the app can detect it is being stopped/terminated so it can cleanup resources (closing files)?</p>