Fix null pointer exception on context destroying.