Try a hard reset.
Hold the top power/sleep button and the home button at the same time until the Apple logo appears, then release.
If that doesn't work, you'll need to Reset All Settings.
Settings >General >Reset >Reset All Settings
You will have to reset everything afterwards. Including alerts, alarms, and everything in Settings.
If the 'flashlight' is still 'on' after 'powering down' the iPhone 4 then the 'flashlight' is not the same as the flashlight feature associated with the iPhone or the iPhone is not turned off.