check if connection etc is null, then close it.