Catch exceptions while disposing