I\'m attempting to automate Coded UI tests.
My test controller launches the tests on a remote test server, which I normally access via a Remote Desktop connection.
I ran into the same issue with our remote test machine, but our test machines run on Hyper-V. With Hyper-V, the solution is simply to connect via Hyper-V instead of Remote Desktop Connection, and closing the Hyper-V connection won't lock the computer.
Another suggestion would be to get around the fact that Remote Desktop automatically locks your screen. There's a quick bit about that here: http://homeservershow.com/remote-desktop-session-locks-workstation-after-exit.html
Basically, run "tscon.exe RDP-Tcp#0 /dest:console" in command prompt from the remote machine when you want to disconnect. The machine should remain unlocked and the tests will run just fine.
According to @Zatricion, that command can be generalized:
tscon.exe %sessionname% /dest:console