Fix pending cleanup on script load error

Script load errors, such as due to a syntax error, would leave pending content on the page, causing the page to never complete. This routes all error handling logic through the load pending object to prevent this block from occurring.