Make keepOpen atomic