Couldn't restore database and couldn't change Single user mode to Multi user mode
Here is what I do to ensure that I get the ONE (1) connection for SINGLE_USER.

USE MyDB;  -- Use the database you want to make SINGLE_USER
GO
ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
RESTORE DATABASE ----; /* Or whatever you need to do. */
GO
ALTER DATABASE MyDB SET MULTI_USER;
GO


The trick is to be in the database already when you switch to SINGLE_USER mode.  This way, you are the SINGLE_USER and nobody else can get in until you return the database to MULTI_USER.  

NOTE: If you exit the database while in SINGLE_USER mode someone else can take over the database.  This can also cause you problems.