The problem seems to be the command button. When placed on a window, setting Message.LongParm in the close event of an application does not return its value to "errorlevel".
I used this cmd file:
@echo off
myApp.exe
echo errorlevel=%errorlevel%
My application:
global variable: long gl_rc = 0
application.open: open( w_appl )
application.close: Message.LongParm = gl_rc
w_appl: sle_rc
w_appl.close: gl_rc = long( this.sle_rc.Text )
Running that application, entering "49" in sle_rc and pressing ALT+F4 results in "errorlevel=49". If I placed an empty command button control on w_appl and re-run the application the result is "errorlevel=0". After removing the command button, it works again as it should. Placing other controls on w_appl (like round rectangle or picture button) has no influence on the correct behavier.
PB 12.6 (4035) on Windows Ultimate 7 and Windows 8.1
Regards Bernhard