[HTC One Mini] elmuziko:
Had a similar experience myself trying to return to stock, for me I was getting cheesed off with the bugs and lack of working bank apps on custom ROMS.

I fixed it by following, and reading in between the lines, on this fellows instructions here.

http://xdaforums.com/htc-one-mini/development/rom-official-stock-android-4-3-sense-5-t2837799

I posted a similar help thread myself a few days ago, someone has replied to say S-OFF isn't crucial to doing this so worth a go maybe. I however did get S-OFF by using the method detailed here.

http://xdaforums.com/showthread.php?t=2573479

I should tell you I was on HBOOT2.19. Not sure how important that is.

So here it was I did to get S-OFF

You've obviously got ADB working on your device so lets skip that.

1.Download revone: http://revolutionary.io/revone and copy it into the same folder as your ADB.

2. Open a CMD prompt and type these commands:

adb push revone /data/local/tmp/

adb shell

chmod 755 /data/local/tmp/revone

Now wait a minute. I found I always got kicked out of the shell after 20 seconds or so, if you do then run adb shell once again.

3. Now type the below text. It is case sensitive so make sure that -P in the second command is uppercase:

cd /data/local/tmp

./revone -P

4.You'll get an error message, it should be "-2". This is good. Restart your phone using the power button.

5.Once you're back in open up the shell again and run the following commands:

adb shell
CD /data/local/tmp
./revone -s 0 -u

BAM! You're now in S-OFF mode.

HBOOT 2.2

I used this thread to get to HBOOT 2.22

http://xdaforums.com/showthread.php?t=2584810

Whilst the instructions are fairly simple I will say it is case sensitive. So when you do

fastboot oem rebootRUU

the RUU has to be in capital letters.

How to return to stock

1. First you need to get yourself TWRP recovery from here: http://teamw.in/project/twrp2/216 and copy the .img file into the same directory as ADB and fastboot.

2. To flash the recovery you need to go into fastboot (hold the power button and the and the volume down button together from a cold boot) and type from a CMD prompt

fastboot flash recovery recovery.img

where recovery.img is the name of the download.

Mine was called openrecovery-twrp-2.7.1.1-m4.img so I'd use this text:

fastboot flash recovery openrecovery-twrp-2.7.1.1-m4.img

3. Once you've flashed the recovery go into recovery and make a backup from the backup menu.

4. Download every file from the link provided in the first post here:

http://xdaforums.com/htc-one-mini/development/rom-official-stock-android-4-3-sense-5-t2837799

5. You're going to have to use WinRAR or 7Archive to unzip the RAR files. You'll get a random folder and a stock recovery.img file.

What I did (or eventually did after lots of trail and error) was attached my phone then deleted the backup content in the TWRP folder. I did NOT delete the folders. Just the files within. Then I copied the extracted content from the download folder into the backup folder I'd just emptied on the phone.

6. Now drop back into the recovery again. First make sure what we did in step 5 worked. If you go into Restore can you see the files we generated earlier? Brilliant. Wipe the cache, factory and delvik (I think Delvik is in the advanced settings, obviously don't have it to hand now i'm back on stock!)

7. Now run a restore which should take a few minutes.

8. Reboot the phone but drop straight back into the Bootloader (power and volume down button pressed)

9. If you haven't copied boot.emmc.win into the ADB folder do so now. Whilst you're at it copy the stock recovery.img file into the same folder and rename it to stockrecovery (take the space out).

From a CMD prompt type :

fastboot flash boot boot.emmc.win/

10. Now we flash the Stock recovery using:

fastboot flash recovery stockrecovery.img

11. Now relock the OEM thingy by using

fastboot oem lock

BAM! You're back to a stock albeit a really crappy version based somewhere in the Middle East. But fear not. Boot in, setup your phone and in the Settings area you can run a software update. This will take you to Android 4.3. Once you're in run another software update to go to 4.4.2 with Sense 5.5. Once you've done that do yet another Software Update to get to 4.4.2 with Sense 6.

At this point I did a factory reset from the settings menu. Not sure if it was needed but just wanted any legacy crap completely killing off.

Also you'll see a message about it being a test device. I Google'd it and people said this is because you're S-OFF. It's not important. Nothing is going to HTC, it's merely a log file thingy.

And that my friend, is how my three day headache got me from a rather buggy custom ROM back to Stock. Enjoy.