Story time: Once upon a time, in the green valley of fileselect, BLI_end_threads would get called on an empty threadbase, depending on the result of a previous call to readdir(). The function would then gladly decrement thread_level to -1 which would cause all kinds of fun havoc. THE END. Made sure thread_level is only incremented and decremented when needed. The caller should never have to make sure of that, especially since it already lets you call with a null threadbase. Please report any further hang (and how to reproduce, if possible).