I think maintenance mode is only a software (php) feature. You can e.g. activate/deactive it with occ or in config/config.php. I think this has no effect on the locked files marked in the database.
Maybe you can better solve your problem. Read this. What is your goal?
I am not sure. But maybe CRON/AJAX cleans up the file locks. Try running CRON for Nextcloud.
sudo -u www-data php -f /path/to/nextcloud/cron.php