Fix search window not always closing

I noticed that if you quickly open & close the search window (clicking x button) after starting visual studio, the window would turn into a black box that never goes away. Turned out to be a null reference exception that prevented ReadyToBeClosed from ever being called.