The problem is, in order to get WiFi working, you need to install the NB1 modules, but to do that, you need to install Safestrap. However, you can not install Safestrap because the app keeps closing on you. There is a simple fix to this, which I will explain later. For now, just read this WHOLE post BEFORE you do anything, and keep in mind that I am NOT held liable if you mess up your phone. Use this at your own risk.
1.) Root your phone
If you're already rooted with something like SuperSU or Superuser, skip this. If not, read ahead. Download and install the Towelroot APK file attached to this post, open it, and click 'make it ra1n'. If your phone didn't reboot, now you have root (they need to trademark that). Now, down below, I also included the APK for SuperSU. Download and install it. Now open it. When you open it, let it install the 'Normal' way, not via the 'TWRP/CWM' way. Also, when it asks you to disable KNOX, say yes, wait a couple of minutes (it will still be loading) and reboot your phone. Open up SuperSU again, click 'Yes' to disable KNOX again, and now you have a good base to start from.
2.) Install Safestrap AFTER fixing the error
The error your are getting is easily fixed. Go to the Play Store and install 'SELinux Mode Changer'. Open it, grant it root access, and change the mode to 'Permissive'. Now, open up Safestrap again (you mentioned you already installed it), and it shouldn't force close. Click 'Install', and if the 'Reboot to Recovery' option below is not grayed out after that then it worked.
3.) Download and install the NB1 modules
On your phone, download the included NB1 modules ZIP file I attached for you, and once that is done you need to reboot. After the Galaxy S4 logo, you'll see a screen that says 'SAFESTRAP: DISABLED' and there will be a little robot. TIP: To enter Safestrap, press the menu button (physical, hardware key) under 'Recovery' at that screen. To continue to Android, press the back key (again, physical) under the 'System' tab. For now, press the menu button under 'Recovery'. Now, click 'Install' which should be in red, click 'Add zips', and navigate to your Downloads folder. Now click on the NB1 modules ZIP you just downloaded. Swipe to install, and reboot. This time, hit the back key under 'System'.
Now, Android should (and will) boot up, and you'll have working WiFi! If, for some odd reason, you don't have WiFi- do NOT panic! Just search around for the MF3 modules and flash those! All is good, all is good. A lot of this guide was taken from my post about my personal method of SIM unlocking the AT&T Galaxy S4 without the dialer codes or an AT&T SIM. It was just modified a little to work for you.
Remember, hit thanks!