How to prepare NextCloud for server shutdown/reboot

What is the proper way to prepare NextCloud for shutting down a server? I am concerned that just issuing a reboot/shutdown command on the server may interrupt background jobs, file or database operations, synchronization with clients, etc and result is data loss or corruption.

I see that NextCloud can be put in maintenance mode by occ. Would that be appropriate/necessary?

sudo halt

should stop all services cleanly and then shut down.

You can see that this is what NextcloudPi uses behind the scenes if you select “poweroff” from the web ui.

No, this is not necessary, as the effect for the user (Nextcloud is no longer running) is identical. Incidentally, it is not Nextcloud that is running, but the web server such as Apache2. Nextcloud is only the manual or automatic call (cron) of PHP scripts. The impression that Nextcloud is running is actually wrong. The same applies to the CMS Wordpress, for example. If neither is currently in use, then nothing will work.