T-Mobile is really taking a run at this whole kinder, gentler carrier thing. Among its many initiatives is the Samsung Galaxy Avant, a modestly specced phone that you can unlock (to use on other carriers) with the newly released SIM unlock app. It might come to more phones later, but it's a step in the right direction anyway.
The app will currently install to any T-Mobile phone—even devices that are already unlocked and weren't purchased directly from Tmo. If you're using a device that isn't supported (currently everything but the Avant), the app will inform you of this. On the Galaxy Avant, you can choose between a permanent unlock and temporary. It doesn't look like an immediate toggle, but probably issues a request to T-Mobile to unlock the device. It usually takes a bit for something like that to go through.
If the device unlock app is updated with support for more phones, it will probably only work for a device that has either been paid off in monthly installments or was purchased for full price.