Today I got an interesting error from one of our db servers. The index maintenance job had failed and in the log I got the following error: Msg 952, Level 16, State 1, Database 'Databasename' is in transition.
When I tried to access the database in SSMS it was not available.
When I ran sp_who2 I saw that there were one session blocking an alter database command from one user. The user blocking had a session open to the database that were unavailable.
I also saw in the sql server logs that the same user had set the database offline the day before. Now it were stuck in between online and offline.
To solve the problem I just killed the blocking session and then the database went offline without any problems.