Release pending items on exception

Continuation of https://github.com/mono/monodevelop/pull/639