Turns out waiting for a while and then running the upgrade via the command line solved the problem.
sudo -u www-data php /var/www/nextcloud/updater/updater.phar
For more information, check out https://help.nextcloud.com/t/updater-app-runs-into-timeout/12891 and the occ upgrade
command in the server manual.