I believe this is possible for
All $M$ and $N$ with $M, N > 1$.
Here are the gadgets I need to prove it. Note that it doesn't matter which corner of the rectangle you start since you can always rotate the picture.

By using gadgets (1) and (2), you can essentially subtract 3 from the height of the grid. (1) works for grids of even width, and (2) works for grids of odd width (just add more up and downs for wider grids). Note that (1) only works on grids of width at least 8, and (2) works for grids of width at least 5.
After subtracting 3 from the height enough times, you'll be left with a grid of height 2, 3, or 4. If the grid is height 2, just zig-zag back and forth and fill in the rest of the grid. If it is of height 3, just repeat gadgets (1) or (2). If it is of height 4, then use gadget (3) for grids of odd width and gadget (4) for grids of even width.
This essentially takes care of all cases except $6 \times 6$. But this is possible too, as shown by gadget (5).