Add history support when opening / closing shell