The hang is due to the race detector being used when os.Exit(0) is called. In Go os.Exit(0) waits for the race detector to complete. If the tests are run without the race detector then the problem doesn't occur. As the builds that run the unit tests don't hang it's likely this is something introduced with newer versions of softhsm as the builds use the version shipped by the repo of the distro being used.
One possibility of the problem is that fabric never bothers to unload the softhsm library (ie never calls Destroy on the pkcs11 3rd party library) but to add that code so that the unit tests can properly clean up is a much larger undertaking and currently is not code that would be called by fabric, however I believe this is an item for graceful shutdown which may make sense for it to clean up pkcs11 resources before terminating.
The easiest solution at this time is just to call syscall.Exit which bypasses the wait for the race detector to finish.