It is possible to do what you want, but you have to go very advanced.
To have direct access to the IR port, you have to use an alternate firmware, such as
BrickOS or
http://lejos.sourceforge.net/]LeJOS. Installation of either of these (especially BrickOS) is extremely difficult on Windows systems. I've never used either on Linux, but the installation should be (in theory), slightly easier.
BrickOS allows you to program the robot in C or C++, while LeJOS uses Java.
--EDIT--
As warned above, check the legality of sending shutdown commands to the RCX. Also, check if alternate firmware is allowed.