IPhone 5S flashes during phone call

When I'm on a phone call the screen flashes on and off and stays off most of the time. I can't end the call or click the speakerphone option. What's causing this and how do I fix this?
Could reinstall the iOS via iTunes... and if the issue persists and is easily replicated - going to an iTunes Genius Bar would let you know what options are... warranty replacement, AppleCare...
Has the screen been replaced? Sounds like its the proximity sensor either malfunctioning or being covered / blocked. Do you have a case on your iPhone?

Original thread: https://forums.imore.com/threads/iphone-5s-flashes-during-phone-call.320583/