While editing in vi, you accidentally end up in the ex editor.
A Q in the command mode of vi invokes ex. Any time you are in ex, the command vi returns you to the vi editor.
Q
vi