SQL Server DB restore fails
Msg 5064, Level 16, State 1, Line 1 Changes to the state or options of
  database 'xyz' cannot be made at this time. The database is in
  single-user mode, and a user is currently connected to it.


This error does not occur if YOU are the single-user in the database.  It only occurs if someone else is in it AND it is ALREADY in single-user mode.

For example, try this:

create database test
--
use test
--
ALTER DATABASE test SET SINGLE_USER WITH ROLLBACK IMMEDIATE
--
ALTER DATABASE test SET SINGLE_USER WITH ROLLBACK IMMEDIATE


Note: there are 4 separate batches, and the 4th one doesn't error.  You're setting the mode while IN the database, and also setting it a 2nd time.  No error.

Assuming you have been given the mandate to restore the DB regardless of what is happening, do an sp_who2 to look for the user who is connected, and KILL the spid.  You can then proceed with the RESTORE.