How to automatically check in files when exiting Visual Studio?

In Visual Studio, please click menu Tools->Options->Source Control->Environment, and then check the Check in everything when closing a solution or project option under Source Control Environment Settings.