Is it ok to simply cap off an unused 240v line in a junction box?
First off, you can simply cap off the wires safely and cover the box. The box must remain accessible though, meaning you can't bury it in the wall.

Second, you CAN install a 50A receptacle on that line if it is for a welder.