You can do
ALTER DATABASE db SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE
and that will only permit users in the db_owner role to connect to the database. (I hope that the web server does not use an application login in that role!)
When you are done, you do:
ALTER DATABASE db SET MULTI_USER
However, I would rather expect that you put a page saying "Maintenance in progress" instead of brutally letting database connections fail.