exit cleanly with cursor positioned correctly