When you forget your icloud password, and if you have the Find my iPhone feature turned on, there is practically no way to log out. The icloud password prompt will keep popping up from time to time to render your iphone/ipad useless.
There is actually a way to remove that icloud username on your device, but it requires jail-breaking. If you are determined then here are the steps.
Jailbreak your device by following this:
https://taig9.com/9.3.5/. You can get Cydia Impactor here.
Follow these steps: http://www.shoutpedia.com/how-to-remove-icloud-account-and-disable-find-my-iphone-on-ios-9-ios-8/. At step 3, the iFile app doesn’t quite work, try to download FileBrowser instead.
Once your clear out the icloud username, those annoying pop up will stopping coming. Now, make sure you get a new iCloud login and write down the password somewhere.