help with windows electric shouters code

Code aside, I would think that you need limit a limit switch (or switches) so that the motor stops on its own when it reaches the extremes of its travel limit. This should happen regardless of what button you’re pressing or not pressing.