You might be able to use Deeplinking special field to set an argument in the launch url
https://sdkdocs.roku.com/display/sdkdoc/Deep+Linkinghttp://<IP of Roku>:8060/launch/?special=<channel to return to ID>You could check if this is present and then set conditional if present on back button launch previous channel.
function main(args={})If back_button_pressed and args.special<>invalid then launchChannel(args.special)end function
Though Certification asks you to return to "Roku Home menu" if back button is pressed on top level screen. Maybe a "Dialog box" asking if user wants to return home or to previous channel