Fix NPE which may happen when opening and closing quickly