Fixed a bug where pressing escape would not properly end scripts in the session state.