I'm sure the NSA didn't have to twist Apple's arm too much to get this done, but Apple has patented a system that tracks iPhones even when they have been switched off. Apple's patent would see the iPhone prompting a user to enter their security code to formally shut it down.
If the code isn't typed in, or it is typed incorrectly a number of times, the phone will appear off. But this isn't the case; the iPhone is still "on" but it appears to be off to the user. While this sounds like a great idea for security, it does mean that Apple could track your iPhone even if you thought it was "off". You would be none the wiser.
This shouldn't come as a surprise to you, as it can be done on Android smartphones right now. This can be tested by having an Android-powered smartphone far away from a cellular tower, and then keep an eye on the battery usage on your smartphone. Researchers have used this method to track an Android smartphone by making a malicious application that didn't have access to Wi-Fi or GPS, and only kept an eye on the power consumption of the phone.