Fixed freezing. Need to fix runtime errors on close.