At the end of the exhaust stroke, just prior to the intake valve opening to allow the fuel mixture in both valves will be closed. Otherwise, if the exhaust valve remains open some of the fuel mixture will get sucked out the exhaust lave. In addition, if the exhaust valve were not closed at the end of the exhaust store, Mr. piston says hi to Mr. valve in a very unkind way.