engine can now exit.

it will save before exiting.
test cases updated.

Signed-off-by: Nicholas Lum <nicholaslum444@hotmail.com>