I disagree in this case with MukatA. Line #50 of Form 1040NR is NOT INTENDED for use to return Stimulus Rebate checks. Make NO MENTION of the stimulus rebate on your Form 1040X or the Form 1040NR. Disregard it completely when preparing the Form 1040X and 1040NR.
When you submit the Form 1040X and Form 1040NR, prepare a separate letter to the IRS explaining that you received the stimulus rebate check in error. If you got the stimulus rebate in the form of a government check, attach that check to the letter and mail it with the Form 1040X.
If you got the simulus rebate via direct deposit, then write a SEPARATE personal check to "U.S. Treasury" for the stimulus amount, put your SSN on the check and attach it to the letter.
Time is of the essense here! If you cannot amend your return quickly (within the next 30 days), then return the stimulus rebate check with the cover letter immediately, mailing it to the IRS office at which you filed your return.
If you retain the check for any significant amount of time (over 60 days), the IRS will charge you interest and MAY assess penalties.