The issue I'm having is that whenever I just remove my USB wifi card, it kernel panics and reboots the system. Is there some way to detect and kill any processes using the wifi card automatically to make some sort of shell script?
I suspect that the issue is with your driver rather than any process using it.
You'll need to make sure that nothing is using it and then remove it with
modprobe -r. Try bringing down the network interface first. For example:
# ip link set wlan0 down # modprobe -r <module>
You can find out the module name using