Destroy allocated resources on exception.