The Desktop Window Manager has exited with code (0x40010004)

This could be because of "Client Compatibility Settings". I had faced the same issue 10 mins ago after licensing my terminal server and this is how I fixed it.

  1. Go to 'Remote Desktop Session Host Configuration'
  2. In the 'Connections' section, right click on your connection name and select 'Properties'
  3. In properties window, go to 'Client Settings' tab
  4. Uncheck 'Limit Maximum Color Depth'
  5. Click apply and ok
  6. Now go to 'Remote Desktop Services Manager'
  7. Select your terminal server from left plane
  8. Right click on each user account under 'Users' tab on right plane and select Log Off

Done! next time users should get successful login.