Fix SearchContext from being closed prematurely

Fixes SearchContext from being closed during initialization or immediately
after processing is started

Closes #5165