It may be possible for a DLL to unload itself but it may cause the process that legitimately loaded the DLL to crash if that proces later calls a function in the DLL.
The link you refer to describes DLL injection which is where the code of a DLL is loaded as part of the address space of a process with a view to intercepting calls the process makes to functions in other "legitimate" DLLs . It is usually done in a "secretive" manner. i.e. the process whose calls are intercepted and rerouted is unaware of the DLL injection.
So the link refers to advanced stuff which is used in rare circumstances.
You are also wondering what to do if a DLL you load throws an exception. You should be able to catch it, but it might not be necessary to unload the DLL. There are OS specific calls on all platforms to unload a shared library. So, yes, you can do it. However it would be unusual to unload a DLL just because it threw an exception. It normally works fine but would cause a problem if another thread in your process is still using code in that DLL (this you would have to be aware of obviously).
The short answer is, yes, you can unload the DLL if you explicitly loaded it. Just think carefully about when is the best time to unload it.
Windows:
LoadLibrary()
FreeLibrary()
GetProcAddress()
Unix/Linux:
dlopen()
dlclose()
dlsym()
PS:I use the one term, DLL in my answer to refer to shared libraries on Windows and Linux.