Prevent menu from going off screen

Fixes #1121